Jump to content

can i call a lua script function, attached to an object from C++?


Charrua
 Share

Recommended Posts

i have many objects with scripts attached

if i get one of them via collision or ray pick, can i call a function declared inside the entity's script?

 

something like

pickinfo.entity.script.Hit(), if Hit is defined inside the script

 

thank's in advance

 

Juan

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

Unless Josh made this easier in Leadwerks, you probably can but it might be ugly. I know Josh has some Lua wrappers exposed.

 

Below is a starting point to see how a "normal" lua function is called. Look at the Lua function here and you should see some similar ones in Leadwerks that Josh wrapped up and you might be able to work it out. If you do, make a nice easy function for the rest of us smile.png

 

Since script functions are table functions the call will be different. You probably have to push the table onto the stack or something like that before making the call.

 

http://www.lua.org/pil/25.2.html

 

It would be really nice if Josh made this really easy though.

 

Something like:

 

pickinfo.entity->script->CallFunction("Hit");

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...