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 25th 2011, 05:57 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Doesn't work. Dink doesn't say anything.

Every running script has a script number. If the same script is running twice (en-pill, for example, but it could be anything), there are two script instances, with each their own local scope. It gets better: if you use "return" in a procedure, the script instance isn't killed. This is what kill_this_task() is for.

Calling another procedure, like procb() and proca() will spawn a new script instance, with their own script number, and own local scope.

So... why even have this whole script-instance stuff? A sprite stores a script number as well, and when you punch it, the engine will make sure that the "hit" procedure of the corresponding script instance is run. The only way to control it through DinkC is the run_script_by_number() function. If a script instance is busy in a wait() somewhere (or in some of the other "pausing commands"), and suddenly the engine, or run_script_by_number() redirects its attention somewhere else, it won't go on past the pausing command. So:
void talk( void )
{
  say("Hello!",&current_sprite);
  wait(10000);
  say("Bye!",&current_sprite);
}

void hit( void )
{
}

If you talk to it, and then punch it within 10 seconds, you'll never see "Bye!", because the engine has redirected the script to run the hit() procedure.

I'm not sure if the hit() actually needs to be present. It probably does.