engine_getscript + wait

Posted By: Helghast

engine_getscript + wait - 01/31/10 10:07

Hi,

Im using engine_getscript to call a function.
But if that function hit's a wait in it, it will get terminated instead.
Why is this, and more importantly, can this be fixed (through a work-around or in the engine)?

regards,
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 09:46

also, sys_exit("whatever in here") quits the game without displaying any string whatsoever. (only when called through engine_getscript).

Hope this helps a bit more.

regards
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 10:02

What is your problem? sys_exit and wait are explained in the manual.

http://manual.3dgamestudio.net/aexit.htm

Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 10:16

yes, but i am talking about a function that runs through engine_getscript.

If the function that runs through this contains a wait, it immediatly get terminated (without doing anything that's still in the function).
Same happens with sys_exit and a string parameter, no string is displayed, engine just shuts down.
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 10:30

That sounds perfectly normal to me. Have you read the manual? Can you describe your problem in detail?
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 10:36

ofcourse;
I'm running this piece of code from a model:

Code:
runStringFunction = engine_getscript(my.string1);
if(runStringFunction) { runStringFunction(); }



which is basically what the manual wrote wink (yes, i have defined "void runStringFunction();" global).

now, whatever function runs off of that works fine, untill the point it hits a wait in it. at that point, the whole function is terminated.
I wanted to know why that happens, and if there is a way around it?

regards,
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 10:38

For the third time: just read the manual. Of course it's terminated because wait always terminates a function.

"Wait temporarily terminates the function (like return), stores its local variables and the my and you pointers, stores the function state in an internal list (Scheduler List), and returns to the calling function (if any)."


A computer does not read your mind - it just does what you tell it to do.
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 13:50

yes, i got that part, it just doesnt return to the calling function after the wait, the whole function stops after it (and doesnt move on the next frame).

I just used the wrong terminology there, i'm sorry, "terminated" should've said "quit without resuming".

The manual doesnt say anything on that (not under engine_getscript or under wait).
Or i'm getting it completely wrong, and the manual should be more clear about that?
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 14:23

Hmm, what do you mean with "it doesn't return to the calling function"? The calling function does not continue?
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 14:28

the function that has the wait in it, doesnt continue running after the wait, when it was called through engine_getscript.
so yes, the calling function does not continue.
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 14:37

I admit that your explanations still don't make any sense to me. If it does not return to the calling function, then where does it return to?

Can you check the return path in the debugger of your development system? Or are you calling engine_getscript not from an external language but from within a script?
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 14:44

I'm calling it from within the script, I'm using this to create Triggers of which I can run custom functions off.
The files are uploaded already, in the contest entry of me.
If needed, I can point out where it occurs.
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 14:46

Why do you call engine_getscript from within a script? This is a function of the SDK, to be used in external languages. In a script, the function pointer is just the name of the function.
Posted By: Helghast

Re: engine_getscript + wait - 02/01/10 14:57

I asked this before, because previously in A6, I could do this with execute.
You suggested back then when i asked for a replacement to use this instead, so I did.

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=247735
Posted By: jcl

Re: engine_getscript + wait - 02/01/10 15:48

Ok, now I at least understand what you want to do. But still I don't know why you have a problem.

When you call a function, it does not matter how you got its pointer, as long as it's the right one. The function itself does not know that you called engine_getscript before. It just executes and returns.

Maybe something else in your project causes a problem? For testing, write a simple script that just gets and calls your function pointer. Check if it returns correctly. Also check if you've defined the prototype correctly and if you're really calling the right function pointer.
Posted By: Helghast

Re: engine_getscript + wait - 02/02/10 08:51

I found out what the problem was;

the entity that calls the function, was removed, thus the handle to you/my was invalid, and the function didnt get executed.
I mis-understood this part, because i was thinking that my handle was the global dummy function i get the handle with (like i showed above).

thanks for the help.
© 2024 lite-C Forums