Jump to content

Custom Lua tables called via Interpreter::EvaluateString


martyj
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...