The Dink Network

A weird question

July 10th 2011, 12:49 PM
boncag.gif
Godley
Peasant They/Them
 
Can we attach a script to a sprite so that the warps it to a different screen, rather than using the standard procedure?
July 10th 2011, 12:50 PM
wizardg.gif
schnapper
Peasant He/Him Heard Island And Mcdonald Islands
Let us save our effort and just lie down and die. 
yes.
July 10th 2011, 12:53 PM
boncag.gif
Godley
Peasant They/Them
 
How?
July 10th 2011, 02:35 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
Look up scripted wraps... I think meta went through it in his tutorial?
July 10th 2011, 02:52 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
Okay, I haven't scripted in dinkC for quite a while and haven't tested this, but here we go:
void main(void)
{
     //makes engine look for touch
     sp_touch(&current_sprite, -1);
}
void touch(void)
{
     //dink touched the wrapping thingy let's freeze him
     freeze(1);

     //change screennumber depending on a variable

     int &snumber;

     if(story < 5)
     {
          &snumber = 103;
     }
     else
     {
          &snumber = 102;
     }
     
     //following part is the wrap (modified from metas tutorial)
     //makes screen black
     fade_down(); 
     //sets the map number from variable from before
     &player_map = &snumber; 
     //loads and draws the new map
     load_screen(); 
     draw_screen();
     //dink will be unfrozen now so let's re-freeze him
     freeze(1); 
     //set x and y coordinates for dink
     sp_x(1, 180); 
     sp_y(1, 250); 
     //make the player see the screen and unfreeze dink!
     fade_up();
     unfreeze(1);
}



Oh and don't use the normal wrap at all, just the script.
July 10th 2011, 02:59 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Look up scripted wraps... I think meta went through it in his tutorial?

Not specifically. But how to change screens in scripts is explained in chapter 11.3. You can simply make an object and use the touch procedure (chapter 10) to make the sprite warp Dink to the correct location. In general the script you'd need would look something like this:

void main(void)
{
sp_touch_damage(&current_sprite,-1);
}
void touch(void)
{
freeze(1);
sp_touch_damage(&current_sprite,0);
fade_down();
script_attach(1000);
&player_map = <screennumber>;
sp_x(1,<x> );
sp_y(1,<y> );
load_screen();
draw_screen();
freeze(1);
fade_up();
unfreeze(1);
kill_this_task();
}

Where <screennumber>, <x> and <y> are the screennumber, the x-coordinate and the y-coordinate of the place you want to warp Dink to. You can also leave out the fade_up and fade_down parts if you want the transition to be sudden rather than gradual. If you want to know why you need these parts I really suggest you read through chapters 10 and 11 of my tutorial!