Jump to content
  • entries
    10
  • comments
    31
  • views
    7,557

LUA CPP "how to" 4/7


Charrua

1,708 views

 Share

3) How to call an entity's script LUA function easely (without parameters)

 

That's really easy. Suppose you have an entity in your scene with a script attached in which a function "noParams" has been declared

 

function Script:noParams()
  System:Print("executing noParams")
end
 

 

using the loop exposed on tut 2/7 of this series, you can find that entity and then, to call one of their functions you only have to do:

 

entity->CallFunction("noParams"); // yes only the name
 

 

also you may check if the entity has a script at all:

 

this is a more generic function to call functions with no parameters:

void call_noParams(Entity* e, string funcName){
  if (e->script != NULL)
    e->CallFunction(funcName); // CallFunction only if entity has a script attached
}

 

 

that's it!

 

Next, Home, Previous

 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

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

×
×
  • Create New...