The Dink Network

Reply to Re: New *WORKING* cross-platform editor

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
June 26th 2011, 05:22 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Not sure what you mean. I have the following code:
// sprite.c
void talk( void )
{
  say_stop("Hi",&current_sprite);
  external("waiter","proc");
  say_stop("Bye",&current_sprite);
}

void hit( void )
{
}

// waiter.c
void proc( void )
{
  wait(5000);
}

And when I talk and wait 5 seconds, it says "Hi" and then "Bye".
When I talk, then hit it before the 5 seconds are over, it says "Hi" but no "Bye".

With &current_sprite being available in an external() script... Let me start somewhere else for a moment.
Every in-game sprite has a script-number. Anything that happens to the sprite (talking, hitting, death, push, desire to attack... those kind of things) will launch a procedure of that script. You can get this script number in DinkC by using the "is_script_attached()" function.

The other thing is that every script has a sprite number. This is the value of &current_sprite. However, it is *not* necessarily true that is_script_attached(&current_sprite) == &current_script. For example: calling external() will keep &current_sprite, but the external-script will be a separate script instance and thus have a different script number than the script that did the call to external().

Finally, using script_attach(), you *only* modify the value of &current_sprite. Checking if &current_sprite is 1000... might actually work. If it does, it'll be the case for spawn()'ed scripts, and for scripts that have used script_attach(1000).
However: It doesn't override the is_script_attached() value of the sprite you attach it to.

As far as I know, the only command that changes the is_script_attached() value of a sprite is sp_script(). However, this spawns a new script number (which gets returned, so you're not completely left in the dark). As far as I know, it's not possible in DinkC to tell the engine "Any hit/talk/etc stuff on this sprite should now run a procedure in this other script number".