The Dink Network

Reply to Re: I love photoshop.

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:
 
 
April 7th 2013, 06:03 PM
custom_marpro.png
Marpro
Peasant He/Him bloop
 
Hi, Kerrek!

First you need to locate the folder called "develop" (it's under the folder-structure where you have installed Dink Smallwood). Open the folder and copy the script called "item-sw1.c". You don't need to edit the script as this point. At some point you might want to, but in this early stage, I think it's better to just use the same sword script as in the main Dink game. Paste the script in to your STORY folder.

Open your editor (WinDinkEditPlus is recommended) and add an object. Add a script to it and open the script (you probably know this already, of course).

Add the following rows:
void main(void)
{
        sp_touch_damage(current_sprite, -1);
}

void hit(void)
{

 	if(&story == 0)
	{
 	add_item("item-sw1",438, 7);
	&story = 1;
	}
	else
	{
	say_stop("I really wanted another sword. *Sob*", 1);
    }
     

}

void touch(void)
{
sp_touch_damage(current_sprite, 0);

 &gold += 100;

//***The part below sees that your chest stays open***

  int &hold = sp_editor_num(current_sprite);

  if (&hold != 0)
    {
     //this was placed by the editor, lets make the chest stay open
     editor_type(&hold, 4); 
     editor_seq(&hold, 177);
     editor_frame(&hold, 6);
     //type means show this seq/frame combo as background in the future
    }

  sp_seq(current_sprite, 177);
  sp_script(current_sprite, "");
  sp_notouch(current_sprite, 1);
  sp_nohit(current_sprite, 1);
  kill_this_task();
 
}


Pretty much the same code as Leprochaun posted, but with the row "add_item("item-sw1",438, 7);" added. I also removed all the "wait(50);" commands, as they're there for no specific reason other than making you confused, in my opinion.

Also, when you're working with touchable objects (void touch) you want to add the "sp_touch_damage(current_sprite, 0);" command. If you exclude this, the script will go bananas when you touch the object and loop too many times (for example, give you 2000 gold instead of the intended 100 gold... Might be handy to know).

(I also added story-progression when you get the sword, you can remove this. Play around with it).

Also, one more.. quick question, it's dumb but how do I make a screentriggered script happen only one? Like if I enter another screen, and go back, the script doesn't trigger?

You could use global variables for this. Like the &story progression. Open your Main.c script and add a custom global variable (under the make_global_int("&story", 0); variable). When you have done your desired action and don't wish it to repeat itself, just follow the example with the &story variable and the sword above. Best of luck!

Edit:

You can probably skip the whole "touch" part, since it would make more sense to have the sword and the gold simultaneously.

void hit(void)
{

 &gold += 100;
 add_item("item-sw1",438, 7);

 int &hold = sp_editor_num(¤t_sprite);

    if (&hold != 0)
    {
     //this was placed by the editor, lets make the chest stay open
     editor_type(&hold, 4); 
     editor_seq(&hold, 177);
     editor_frame(&hold, 6);
     //type means show this seq/frame combo as background in the future
    }

  sp_seq(current_sprite, 177);
  sp_script(current_sprite, "");
  sp_notouch(current_sprite, 1);
  sp_nohit(current_sprite, 1);
  kill_this_task();

}