Advertisement

[LUA] How can I run the Script from another lua file?

Started by January 06, 2005 01:45 PM
3 comments, last by rogerdv 20 years, 1 month ago
Hi again, I have some question about LUA. Can I run the function in another lua'sfile in the script? for example: -------------a.lua--------- function main() --load b.lua --run main2() end ------------b.lua----------- function main2() print("main2") end How can make it work? please tell me. Thanks, from Rookie
Quote:
Original post by Rookie_Max
Hi again,
I have some question about LUA.
Can I run the function in another lua'sfile in the script?
for example:
-------------a.lua---------
function main()

--load b.lua
--run main2()


end

------------b.lua-----------
function main2()
print("main2")

end

How can make it work?
please tell me.

Thanks,
from
Rookie


Example:
dofile("b.lua")
main2()

Try reading the manual and PIL from the lua website..
Ad: Ancamnia
Advertisement
Thx a lot: ;)
One more question, Do I need close the file after the function is called?
Quote:
Original post by Rookie_Max
Thx a lot: ;)
One more question, Do I need close the file after the function is called?


No, you don't need to close the file. dofile() just executes the lua script file. I think there are also other ways to include script files but you'll have to see the manual for that.
Ad: Ancamnia
I think you can even place code in a variable and execute that variable.

This topic is closed to new replies.

Advertisement