0 Replies - 60 Views - Last Post: Yesterday, 06:30 PM Rate Topic: -----

#1 Nicky24  Icon User is offline

  • D.I.C Head

Reputation: 4
  • Posts: 60
  • Joined: 23-December 13

Executing functions in Lua tables from C++

Posted Yesterday, 06:30 PM

Hello everyone!
I would like to know if it is possible to do something like this in Lua and call it from C++:

NPC =
{
	Nicky =
	{
		position =
		{
			x = 100,
			y = 300
		},
		interaction =
		{
			say("How are you?")
		}
	}
}


I already have developed a LuaScript class that can do this to get a value from an array/table:

// Get the position
position.x = script.get<float>("NPC.Nicky.position.x");
position.y = script.get<float>("NPC.Nicky.position.y");


But now I would like to be able to execute that say() function from C++:

script.execute("NPC.Nicky.interaction.say");


How can I do this? I tried to do that by it seems that the function executes by it-self without the instruction of doing so...

Thanks

Is This A Good Question/Topic? 0
  • +

Page 1 of 1