LUA CPP "how to" 4/7
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!
0 Comments
Recommended Comments
There are no comments to display.