Reply to Re: Creating D-mods
If you don't have an account, just leave the password field blank.
Don't forget to give it a touch damage of -1 first. Otherwise the touch procedure will not be run.
A full script would be something like this:
(comments included...)
void main(void)
{
//set the touch damage, just in case we forgot to do this in the editor:
sp_touch_damage(¤t_sprite,-1);
}
void touch(void)
{
//Set back the touch damge to zero so it can't be run again until it's finished.
//It shouldn't be a problem in this script though, but just to obtain good habits:
sp_touch_damage(¤t_sprite,0);
//Next we check wether Dink has enough space in his backpack:
int &hold = free_items();
if (&hold < 1)
{
say("Ahh, I'm carrying to much...",1);
//Here you'd better make sure that Dink walks away before setting the touch damage back to -1.
//If you don't the script could repeat forever.
sp_touch_damage(¤t_sprite,-1);
return;
}
//If the script is here Dink has space in his backpack so let's give the item to Dink:
add_item("item-sw1",438,7);
say("Yipee, a sword!",1);
//Now let's kill of this sprite forever so Dink can only get this item once:
//If you want Dink to be able to get an infinite amount of this item, remove the next lines.
//This only works if the sprite is placed in the editor!!
&hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
{
editor_type(&hold,1);
}
sp_active(¤t_sprite,0);
}
A full script would be something like this:
(comments included...)
void main(void)
{
//set the touch damage, just in case we forgot to do this in the editor:
sp_touch_damage(¤t_sprite,-1);
}
void touch(void)
{
//Set back the touch damge to zero so it can't be run again until it's finished.
//It shouldn't be a problem in this script though, but just to obtain good habits:
sp_touch_damage(¤t_sprite,0);
//Next we check wether Dink has enough space in his backpack:
int &hold = free_items();
if (&hold < 1)
{
say("Ahh, I'm carrying to much...",1);
//Here you'd better make sure that Dink walks away before setting the touch damage back to -1.
//If you don't the script could repeat forever.
sp_touch_damage(¤t_sprite,-1);
return;
}
//If the script is here Dink has space in his backpack so let's give the item to Dink:
add_item("item-sw1",438,7);
say("Yipee, a sword!",1);
//Now let's kill of this sprite forever so Dink can only get this item once:
//If you want Dink to be able to get an infinite amount of this item, remove the next lines.
//This only works if the sprite is placed in the editor!!
&hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
{
editor_type(&hold,1);
}
sp_active(¤t_sprite,0);
}