Converting lists to tables in lua
Posted: Tue Apr 07, 2015 12:10 am
by Noobasaurus
I was told that since I have some lovely lists of if/then statements that I should post them here and get help on how to make them into an organized table. Here's one of my lists:
As usual, help with doing this is much appreciated.
Hidden/Spoiler:
[code]
function resourceUpdater()
print("resourceUpdater")
wood = Curwood + wood
Curwood = 0
stone = Curstone + stone
Curstone = 0
SetTeamPoints(1, Curwood)
SetTeamPoints(2, wood)
if wood >= 450 and wood < 500 then
RespawnObject("logs")
KillObject("logs1")
KillObject("logs2")
KillObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 900 and wood < 950 then
RespawnObject("logs1")
KillObject("logs2")
KillObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 1350 then
RespawnObject("logs2")
end
if wood < 450 then
KillObject("logs")
KillObject("logs1")
KillObject("logs2")
end
if wood >= 50 and wood < 100 or wood >= 500 and wood < 150 or wood >= 950 and wood < 1000 or wood >= 1400 and wood < 1450 then
RespawnObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 100 and wood < 150 or wood >= 550 and wood < 600 or wood >= 1000 and wood < 1050 or wood >= 1450 and wood < 1500 then
RespawnObject("log1")
RespawnObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 150 and wood < 200 or wood >= 600 and wood < 650 or wood >= 1050 and wood < 1100 or wood >= 1500 and wood < 1550 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 200 and wood < 250 or wood >= 650 and wood < 700 or wood >= 1100 and wood < 1150 or wood >= 1550 and wood < 1600 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 250 and wood < 300 or wood >= 700 and wood < 750 or wood >= 1150 and wood < 1200 or wood >= 1600 and wood < 1650 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 300 and wood < 350 or wood >= 750 and wood < 800 or wood >= 1200 and wood < 1250 or wood >= 1650 and wood < 1700 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 350 and wood < 400 or wood >= 800 and wood < 850 or wood >= 1250 and wood < 1300 or wood >= 1700 and wood < 1750 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
RespawnObject("log8")
KillObject("log9")
end
if wood >= 400 and wood < 450 or wood >= 850 and wood < 900 or wood >= 1300 and wood < 1350 or wood >= 1750 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
RespawnObject("log8")
RespawnObject("log9")
end
end
[/code]
function resourceUpdater()
print("resourceUpdater")
wood = Curwood + wood
Curwood = 0
stone = Curstone + stone
Curstone = 0
SetTeamPoints(1, Curwood)
SetTeamPoints(2, wood)
if wood >= 450 and wood < 500 then
RespawnObject("logs")
KillObject("logs1")
KillObject("logs2")
KillObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 900 and wood < 950 then
RespawnObject("logs1")
KillObject("logs2")
KillObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 1350 then
RespawnObject("logs2")
end
if wood < 450 then
KillObject("logs")
KillObject("logs1")
KillObject("logs2")
end
if wood >= 50 and wood < 100 or wood >= 500 and wood < 150 or wood >= 950 and wood < 1000 or wood >= 1400 and wood < 1450 then
RespawnObject("log1")
KillObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 100 and wood < 150 or wood >= 550 and wood < 600 or wood >= 1000 and wood < 1050 or wood >= 1450 and wood < 1500 then
RespawnObject("log1")
RespawnObject("log3")
KillObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 150 and wood < 200 or wood >= 600 and wood < 650 or wood >= 1050 and wood < 1100 or wood >= 1500 and wood < 1550 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
KillObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 200 and wood < 250 or wood >= 650 and wood < 700 or wood >= 1100 and wood < 1150 or wood >= 1550 and wood < 1600 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
KillObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 250 and wood < 300 or wood >= 700 and wood < 750 or wood >= 1150 and wood < 1200 or wood >= 1600 and wood < 1650 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
KillObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 300 and wood < 350 or wood >= 750 and wood < 800 or wood >= 1200 and wood < 1250 or wood >= 1650 and wood < 1700 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
KillObject("log8")
KillObject("log9")
end
if wood >= 350 and wood < 400 or wood >= 800 and wood < 850 or wood >= 1250 and wood < 1300 or wood >= 1700 and wood < 1750 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
RespawnObject("log8")
KillObject("log9")
end
if wood >= 400 and wood < 450 or wood >= 850 and wood < 900 or wood >= 1300 and wood < 1350 or wood >= 1750 then
RespawnObject("log1")
RespawnObject("log3")
RespawnObject("log4")
RespawnObject("log5")
RespawnObject("log6")
RespawnObject("log7")
RespawnObject("log8")
RespawnObject("log9")
end
end
[/code]