The Dink Network

Reply to Re: Savebot script

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:
 
 
August 29th 2011, 09:38 AM
spike.gif

//script where duck is created
&quack = create_sprite(289, 220, 3, 21, 1);
sp_script(&quack, "duck1");

//duck1.c script
void main(void)
{
sp_speed(&quack, 1);
sp_hitpoints(&quack, 10);
sp_base_walk(&quack, 20);


Something like this can't work unless &quack is a global... Local variables only work inside the same script where you create them. When the game switches to the duck1.c script, it has no idea who the duck &quack is supposed to be anymore. You need to use &current_sprite instead. Or you can do this:

//script where duck is created
int &quack = create_sprite(289, 220, 3, 21, 1);
sp_script(&quack, "duck1");

//duck1.c script
void main(void)
{
int &quack = &current_sprite;
sp_speed(&quack, 1);
sp_hitpoints(&quack, 10);
sp_base_walk(&quack, 20);