martyj Posted August 16, 2017 Share Posted August 16, 2017 I'm working on customizing quests with Lua to be more dynamic. I'd like to be able to define a lua program via a lua file, load it via Interpreter::EvaluateFile. After loading the file, I'd like to be able to call a "Main" function inside the file. Something similar to the following: ----- Scripts/Quests/ARudeAwakening.lua ARudeAwakening = {} function ARudeAwakening:Main() System:Print("Main loaded") App.Quests.ARudeAwakening = self end function ARudeAwakening:UpdateWorld() System:Print("Logic Stuff") end ---- C++ Interpreter::EvaluateFile(std::string("Scripts/Quests/ARudeAwakening.lua")); Interpreter::EvaluateString(std::string("ARudeAwakening:Main()")); How can I get something like this to work? Quote Link to comment Share on other sites More sharing options...
Rick Posted August 16, 2017 Share Posted August 16, 2017 Have you tried the following? Does it give an error? Quote Link to comment Share on other sites More sharing options...
martyj Posted August 17, 2017 Author Share Posted August 17, 2017 22 hours ago, Rick said: Have you tried the following? Does it give an error? I've updated the lua code to the actual Lua code, not just psudocode. The code "Runs" but nothing is printed to the console. If I run Interpreter::EvaluateString(std::string("System:Print(\"Test\")")); This will print to the console. I haven't ran it through a Lua debugger to see if ARudeAwakening::Main() gets called or not. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.