martyj Posted August 16, 2017 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
Rick Posted August 16, 2017 Posted August 16, 2017 Have you tried the following? Does it give an error? Quote
martyj Posted August 17, 2017 Author 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
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.