The Dink Network

Reply to could use some help with my 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:
 
 
July 7th 2010, 06:01 AM
peasantfr.gif
I just started to create my first D-mod. But am stuck on creating a script for a fence that can open and close.

I just posted the script as I made it. With explenation on why I did things (mainly to keep track of things myself).

If you enter the screen you can interact with the fence as intended, but when you leave and come back it goes wrong. if I closed the fences before leaving the screen, they are gone when I come back and if I opened them before leaving the screen, they show open when I come back but I can't talk to them anymore.

I tried giving them a brain 5 but then I can't talk to the fence after the first time opening it so that makes it just worse. The use of visions is not possible since dink is in the screen. I tried a lot of different things but nothing really works, it either screw up the hardness or the ability to talk to it.


the script:


void main (void)
{
preload_seq(35);
//secuence for closing the fence
preload_seq(36);
//secuence for opening the fence

	int &donk = sp_editor_num(&current_sprite);
	editor_type(&donk, 0);
	int &myflag = editor_seq(&donk, -1);
// I made variable &myflag to track if the fence is open (1) or closed (0)

	int &donk2 = sp_editor_num(&current_sprite);
	editor_type(&donk2, 0);
	int &myflag2 = editor_seq(&donk2, -1);
// I made variable &myflag2 to change &myflag at the end of the script if the fence opens of closes
}

void talk(void)
{ 

freeze(1);
//freeze dink

 if (&myflag == 0)
// look if fence is closed If closed: 
	{
	choice_start()
	"open fence"
	"leave fence"
	choice_end();
	//give the option to open the fence of to just leave it as it is

	if (&result == 1)
	// procedure for opening the fence
       		{
		wait(400);       
		playsound(7, 22050, 0,0,0);

		int &hold = sp_editor_num(&current_sprite);

		editor_type(&hold, 2);
		editor_seq(&hold, 36);
		editor_frame(&hold, 5);

		sp_seq(&current_sprite, 36);
		sp_hard(&current_sprite, 1);
		draw_hard_sprite(&current_sprite);
         
		&myflag2 = 1;
		//adjust &myflag2 to change the value of &myflag at the end of the script
		}
	}

if (&myflag == 1)
// look if fence is closed If open:
//(because &myflag gets edited at the end of the script it doesn't count closed as it is just closed by the above part of the script)
	{ 
	choice_start()
	"close fence"
	"leave fence"
	choice_end();
	//give the option to close the fence of to just leave it as it is

		if (&result == 1)
		// procedure for closing the fence
		{
		move_stop(1, 2, 300,1);
		move_stop(1, 4, 73, 1);
         
		// move dink so he wont get stuck in the harness of the fence when it is reaplied
		wait(200);
		playsound(7, 22050, 0,0,0);
	
		int &hold = sp_editor_num(&current_sprite);
         
		editor_type(&hold, 4);
		editor_seq(&hold, 35);
		editor_frame(&hold, 5);

		sp_seq(&current_sprite, 35);
		sp_hard(&current_sprite, 0);
		draw_hard_sprite(&current_sprite);

		&myflag2 = 0;
		//adjust &myflag2 to change the value of &myflag at the end of the script
		}
	}

&myflag = &myflag2;
//adjust &myflag with &myflag2 so the it corresponds with the status of the fence

unfreeze (1);
// unfreeze dink
}


Edited so code is better readable, thanks MsDink for the tip on how to do that