Author Topic: calling objects script functions from within the engine code?  (Read 86 times)

0 Members and 1 Guest are viewing this topic.

argoon

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +21/-81
  • Doom Newbie
    • View Profile
Hello guys and gals,  i'm trying to call functions from the c++ code, like i used to do using DoomScript but obviously is different on the c++ side, studying the engine code i see id calls scripts like so:

Code: [Select]
const function_t *func;

func = Entity->scriptObject.GetFunction("somefuncname");
Thread->CallFunction(frobableEntity, func, true);

but this just crash's the engine for me and i'm totally clueless why.

Any help is welcome.


 Edit: before posting this i spend more than a hour trying to make this work, after making this thread and going away to try to solve again i did it: :P  :D

This is the necessary code to successfully call object script functions from withing the c++ code:

Code: [Select]
const function_t *func;
idThread *Thread;

func = Entity->scriptObject.GetFunction("signalOn");
Thread = new idThread();
Thread->CallFunction(Entity, func, true);
Thread->Start();
« Last Edit: July 11, 2017, 12:23:28 PM by argoon »