Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!