Any way to fix this?
Here's what I got so far:
Code: Select all
local currencies = require("currencies")
local starcoin_currency = currencies.registerCurrency(currencies.CURRENCY_STARCOINS)
starcoin_currency:registerLimit(400, function() end)
-- onDraw can be used to draw the currencies
function onDraw()
starcoin_currency:draw()
end
nvm i figured it out
i had to copy some code from starcoin.lua into the luna.lua for some reason
Code: Select all
local currencies = require("currencies")
local starcoin_currency = currencies.registerCurrency(currencies.CURRENCY_STARCOINS)
starcoin_currency:registerLimit(400, function() end)
local starcoin = require("npcs/ai/starcoin")
local checkpoints = require("checkpoints")
local collected = false
local UNCOLLECTED = 0
local SAVED = 1
local COLLECTED = 2
local COLLECTED_WEAK = 3
local LevelName = Level.filename()
local CoinData = SaveData._basegame.starcoin[LevelName]
if not isOverworld then
if not SaveData._basegame.starcoin[LevelName] then
SaveData._basegame.starcoin[LevelName] = {}
end
function starcoin.getTemporaryData()
return CoinData
end
function starcoin.max()
return CoinData.maxID
end
CoinData.alive = {}
CoinData.maxID = CoinData.maxID or 0
function starcoin.registerAlive(id)
CoinData.alive[id] = true
if id > CoinData.maxID then
CoinData.maxID = id
end
end
--Called from npc-310 to make sure it runs at the right time
function starcoin.init()
-- Reset states
local activeCheckpoint = checkpoints.getActive()
for i = 1,CoinData.maxID do
if (CoinData[i] == COLLECTED and not activeCheckpoint) or CoinData[i] == COLLECTED_WEAK then
CoinData[i] = 0
end
end
end
function starcoin.collect(coin)
local coinEffect
if CoinData[coin.ai2] and CoinData[coin.ai2] > UNCOLLECTED then
coinEffect = Effect.spawn(233, coin.x + coin.width*0.5, coin.y + coin.height*0.5)
else
coinEffect = Effect.spawn(276, coin.x + coin.width*0.5, coin.y + coin.height*0.5)
end
coinEffect.x = coinEffect.x - coinEffect.width/2
coinEffect.y = coinEffect.y - coinEffect.height/2
if CoinData[coin.ai2] == UNCOLLECTED and starcoin.getLevelCollected() + 1 >= starcoin.count() then
SFX.play(starcoin.sfx_collectall)
else
SFX.play(starcoin.sfx_collect)
end
if coin.ai2 > UNCOLLECTED then
if CoinData[coin.ai2] == UNCOLLECTED then
CoinData[coin.ai2] = COLLECTED_WEAK
end
local HO = hudoverride.offsets.starcoins
local currRow = math.floor((coin.ai2 - 1)/HO.grid.width)
if currRow < HO.grid.offset or currRow > HO.grid.offset + HO.grid.height - 1 then
HO.grid.offset = currRow
end
end
--mem(0x00B2C8E4, FIELD_DWORD, mem(0x00B2C8E4, FIELD_DWORD) + 4000)
--local pointEffect = Effect.spawn(79, coin.x + coin.width/2, coin.y, 8)
--pointEffect.x = pointEffect.x - pointEffect.width/2
--pointEffect.animationFrame = 7
Misc.givePoints(NPC.config[coin.id].score, coin, true)
coin:kill(9)
end
end
function onTick()
for i = 1,CoinData.maxID do
if CoinData[i] and CoinData[i] >= COLLECTED then
CoinData[i] = SAVED
SaveData._basegame.starcoinCounter = SaveData._basegame.starcoinCounter + 1
end
end
starcoin_currency.setMoney = function(c, value)
SaveData._basegame.starcoinCounter = value
end
starcoin_currency.getMoney = function(c)
c._value = SaveData._basegame.starcoinCounter
return SaveData._basegame.starcoinCounter
end
starcoin_currency.addMoney = function(c, value)
SaveData._basegame.starcoinCounter = SaveData._basegame.starcoinCounter + value
end
starcoin_currency.compareMoney = function(c, value)
return SaveData._basegame.starcoinCounter >= value, SaveData._basegame.starcoinCounter - value
end
if starcoin.getLevelCollected(Level.filename()) >= starcoin.count() and not collected then
collected = true
end
end
-- onDraw can be used to draw the currencies
function onDraw()
starcoin_currency:draw()
end