-- COMES AFTER UI.LUA Stones = 150.0 -- Current Stone Stock crafter = {} for i=0, 50 do local dig = {} dig.title = "D" dig.own = false dig.readyTime = 10 -- time until active in Sec dig.ready = 10 dig.speed = 0.5 -- Speed in Sec dig.amount = 1 -- Amount by Sec dig.upCost = 50 -- Stones req to dig twice more 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 updateStocks(sec) for i=1, #crafter do local crft = crafter[i] if crft.ready == 0 then Stones = Stones + (crft.amount * sec * crft.speed) else if crft.own then crft.ready = crft.ready - sec if crft.ready < 1 then crft.ready = 0 crft.ui.color = colorOrange end end end end end function upgradeCrafter(crft) -- BUY CRAFTER if not crft.own then if pay(50) then crft.own = true end -- UPGRADE CRAFTER elseif crft.ready == 0 and pay(50) then crft.amount = crft.amount + 1 end end function pay(cost) if Stones >= cost then Stones = Stones - cost return true else return false end end