The Dink Network

Reply to Re: Returning values from external

If you don't have an account, just leave the password field blank.
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
May 27th 2020, 11:20 PM
Jester Male Australia
You feed the madness, and it feeds on you. 
Yep, I stumbled upon this when developing push and pull, and got just as excited =D

This is how I managed to limit the scripts that need to be edited to just 1 script, even though there's over 10 scripts that work to make this system function properly, which all do calculations based on the numbers inputted in the original script. Things just get processed differently depending on what sp_custom values the author sets and stuff and passed onwards to other externals, where they are altered and then the new value returned back into the original calling procedure for the calculation to continue where it left off.. this is sort of how the collision system works.
Stacking them works the same way:

// Script exttest.c
 external("test", "thingy", 1);
 say_stop("&return", 1);

//script test.c
void thingy(void)
 int &crap = &arg1;
 &crap += 1;
 external("test2", "thingy2", &crap);

//script test2.c
void thingy2(void)
 int &crap = &arg1;
 &crap += 1;

Dink will say "3".


I copied your script examples though, and for me the say_stop lines were not skipped in the second instance for me. Dink said "0" though, which is expected, because as in the DinkC reference, the external function itself does not return a value. As you discovered, you are actually returning a value using the pseudo variable &return, which indeed returns the last known return value from a function or procedure.

But it's exciting stuff.