Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[update = {
- gather = function()
- energy()
- construction()
- }]]
- --goal engine includes
- --drone resource updates
- --drone train time
- --pool spawn time
- --larvae spawn rate
- minerals = 50
- gas = 0
- supply = 6
- supplycap = 14
- pool = false
- queen = 1
- local startTime = os.clock()
- t = math.floor(os.clock() - startTime)
- local gametick = 1
- --if timeTable
- timeTable = {
- ["assign"] = function(t,func)
- if not timeTable[t] then
- timeTable[t] = {}
- end
- table.insert(timeTable[t],func)
- end,
- --doesn't take floating times
- --doesn't take 2 events at same time
- }
- units = {
- ["drone"] = {
- ["update"] = function(self)
- minerals = minerals + (gametick*(self.number * self.rate))
- end,
- ["number"] = 12,
- ["rate"] = 1.2852,
- ["train"] = function()
- minerals = minerals - 75
- supply = supply + 1
- units.larvae.number = units.larvae.number - 1
- --assign to t = number
- if not timeTable[t+22] then
- timeTable[t+22] = {}
- end
- table.insert(timeTable[t+22],function()
- units.drone.number = units.drone.number + 2;
- end)
- end,
- },
- ["larvae"] = {
- ["number"] = 3,
- ["spawning"] = false,
- ["update"] = function(self)
- if not self.spawning and self.number<6 then
- --should be 12.5
- self.spawning = true
- if not timeTable[t+12] then
- timeTable[t+12] = {}
- end
- table.insert(timeTable[t+12],function()
- units.larvae.number = units.larvae.number + 1
- units.larvae.spawning = false
- end)
- end
- end,
- },
- ["queen"] = {
- ["update"] = function()
- end,
- ["number"] = 0,
- ["rate"] = .69,
- ["energy"] = 0,
- ["cost"] = 150,
- },
- ["ling"] = {
- ["update"] = function()
- end,
- ["number"] = 0,
- ["cost"] = 44,
- },
- ["overlord"] = {
- ["number"] = 0,
- ["train"] = function()
- minerals = minerals - 100
- units.larvae.number = units.larvae.number - 1
- timeTable.assign(t+21,
- function()
- units.overlord.number = units.overlord.number + 1
- supplycap = supplycap + 8
- end
- )
- end
- },
- }
- structures = {
- ["pool"] = {
- ["number"] = 0,
- ["cost"] = 200,
- ["constructionTime"] = 25
- },
- }
- while true do
- shell.run("clear")
- --term.setCursorPos(1,1)
- print("minerals: "..minerals)
- print("gas: "..gas)
- print("supply: "..supply.."/"..supplycap)
- print()
- print("larvae: "..units.larvae.number)
- print("drones: "..units.drone.number)
- print("overlords: "..units.overlord.number)
- print()
- print("time: "..t)
- local tick = os.startTimer(gametick)
- local events = {os.pullEvent()}
- if events[1] == "timer" and events[2] == tick then
- --ai
- if (supplycap - supply) <= 2 and minerals > 150 and units.larvae.number>0 then
- units.overlord.train()
- elseif minerals > 75 and supply+1<=supplycap and units.larvae.number>0 then
- units.drone.train()
- end
- for i,v in pairs(timeTable) do
- if tonumber(i) and t == (i*(1/gametick)) then
- --error("HIT")
- for _,f in pairs(v) do
- f()
- end
- end
- end
- for i,v in pairs(units) do
- if v.update then
- v:update()
- end
- end
- end
- t = math.floor(os.clock() - startTime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement