Posted 16 July 2013 - 05:37 PM
Hey guys,
*Pls dont mind the typo in the title :)/> *
Is there any way for a loaded API to call a Function that is in the script in wich the API is loaded?
I cant think of any better way to describe it so i try to show it on the problem i have:
This is a part of the API i wrote, the problem is now that i try to have a function call for a function that isnt in the API itself but is defined and executed in the main script. Here it is the update() function that is called after goToPos().
The main code could look like this:
Thanks in advance if someone knows the answer to this or give a hint to a better solution.
*Pls dont mind the typo in the title :)/> *
Is there any way for a loaded API to call a Function that is in the script in wich the API is loaded?
I cant think of any better way to describe it so i try to show it on the problem i have:
This is a part of the API i wrote, the problem is now that i try to have a function call for a function that isnt in the API itself but is defined and executed in the main script. Here it is the update() function that is called after goToPos().
function gotoTable()
loadConfig()
loadTarget(true)
print(config["start"].." "..#target)
local i = config["start"]
while i <= #target do
if target[i] == "home" then
-- go to deploy pos
else
goToPos(target[i][1],target[i][2],target[i][3],config["goto"])
update()
i = i + 1
config["start"] = i
save(config,"config")
savePos()
end
end
end
The main code could look like this:
local testVar = 1
os.loadAPI("TheAPI")
function update()
print("yay i cant believe this works")
testVar = testVar + 1
end
TheAPI.gotoTable()
Thanks in advance if someone knows the answer to this or give a hint to a better solution.
Edited on 16 July 2013 - 03:38 PM