The Dink Network

Reply to Why can't I quit you, DinkC?

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:
 
 
October 9th 2013, 04:53 AM
custom_coco.gif
cocomonkey
Bard He/Him United States
Please Cindy, say the whole name each time. 
Edit: I decided to change the topic title to reflect the fact that this has become more of a general "scripting problems" thread.

I don't know if anybody else has ever done this, but I got sick of having to use global variables to make sure that one-time events don't happen after the first time you see them, so I came up with a different method.

I have a sprite somewhere on the screen, make it not draw, and give it brain 2 (because that brain is hardly ever used). I use get_sprite_with_this_brain to look for brain 2 sprites before executing the event (use wait(1) first so the sprite in question is sure to do its thing). Then I have whatever event transpires kill this sprite using editor_type!

That sounds like a lot of work, but it really isn't. The "event killer" sprites all have the same script attached. Figuring out that this worked (I've tested it) was a big relief to me, as I wanted many things to happen just once in "Malachi the Jerk," but didn't want a whole mess of variables to keep track of whether they'd happened.

What's weird is that I discovered the engine is picky about get_sprite_with_this_brain, at least as concerns if statements.

if (get_sprite_with_this_brain(2, 0) != 0)
{
//this will never, ever run for some reason.
}

if (get_sprite_with_this_brain(2, 0) > 0)
{
//But this works.
}


Let me know if I overlooked some simpler way of doing the same thing. It's certainly possible.

I wasn't sure whether to put this in its own topic or my DMOD topic. Sorry if I put it in the wrong place.