So basically what I would like is to have is when you have a set of functions in a table, to be able to call it like print(timeRequirements[3]()) , to do the same as print(timeRequirements["old_man"]()
Here is my table code:
timeRequirements = {
bulbasaur = function() --RESET
if BEAST_MODE then
return 1.99
end
return 2.22
end,
nidoran = function() --RESET
if BEAST_MODE then
return 6
end
return 6.4 + timeSaveFor("spearow")
end,
old_man = function()
return 6.75 + timeSaveFor("spearow")
end,
forest = function()
return 9.33 + timeSaveFor("spearow")
end,
brock = function()
return 11 + timeSaveFor("spearow")
end,
shorts = function() --TWEET
local timeLimit = 13.75 + timeSaveFor("spearow")
timeLimit = timeLimit + (3 - stats.nidoran.rating) * 0.2
return timeLimit
end,
mt_moon = function() --RESET
if BEAST_MODE then
return 24.75
end
local timeLimit = 25.50 + timeSaveFor("paras")
if Pokemon.info("nidoking", "level") >= 18 then
timeLimit = timeLimit + 0.33
elseif Pokemon.getExp() > 3730 then
timeLimit = timeLimit + 0.15
end
if stats.nidoran.attack > 15 then
timeLimit = timeLimit + 0.25
end
if stats.nidoran.speed > 14 then
timeLimit = timeLimit + 0.25
end
return timeLimit
end,
mankey = function()
return 31.25 + timeSaveFor("paras")
end,
bills = function()
return 36 + timeForStats() + timeSaveFor("paras")
end,
misty = function() --PB
return 37.75 + timeForStats() + timeSaveFor("paras")
end,
vermilion = function()
return 42.25 + timeForStats()
end,
trash = function() --RESET
if BEAST_MODE then
return 45.75
end
return 47.25 + timeForStats()
end,
safari_carbos = function()
return 68.25 + timeForStats()
end,
victory_road = function() --PB
return 97.3
end,
e4center = function()
return 99.75
end,
blue = function()
return 106.25
end,
champion = function() --PB
return 112
end,
}
It should return "6.75"
I don't really know how to do this, I tried a few things and all ended up returning
LuaInterface.LuaScriptException: [string "main"]:108: attempt to index field '?' (a nil value)
I would like to return the 3rd function in the tunnel.
timeRequirements[3]betimeRequirements["old_man"]? Because it happens to be the third one in your source code? Table keys aren't ordered.