-- COMES AFTER UI.LUA Stones = 30.0 -- Current Stone Stock StonesSec = 0 crafter = {} for i=0, 50 do local dig = {} dig.title = "D" dig.own = false -- is it bought ? dig.active = false -- is it active yet ? dig.readyTime = 10 -- time until active in Sec dig.ready = 0 -- current time until readyTime dig.speed = 0.3 -- Speed in Sec dig.amount = 0.1 -- Amount by Sec dig.cost = 10 local xg = (i%20)*50 local yg = 50 + math.floor(i/20)*50 dig.ui = {color = colorBlue, x = xg, y = yg, w = 50, h = 50} dig.uiready = {color = colorOrange, x = xg, y = yg+50, w = 50, h = 0} table.insert(crafter, dig) end function updateCraft(sec) for i=1, #crafter do local crft = crafter[i] if not crft.active and crft.own then if crft.ready >= crft.readyTime then crft.active = true recalcStonesSec() end crft.ready = crft.ready + sec end end end function recalcStonesSec() local stsec = 0 for i=1, #crafter do local crft = crafter[i] if crft.active then stsec = stsec + crft.amount * crft.speed end end StonesSec = stsec end function upgradeCrafter(crft) -- BUY CRAFTER if not crft.own then if pay(crft.cost) then crft.own = true end -- UPGRADE CRAFTER elseif crft.active and pay(crft.cost) then crft.amount = crft.amount + 0.05 crft.cost = math.floor(crft.cost * 1.5) end end function pay(cost) if Stones >= cost then Stones = Stones - cost return true else return false end end