The Dink Network

Reply to Re: Shawn Teal conspiracy theory

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 2nd 2021, 10:53 AM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
I know of two other methods that also work, which can use fewer global
variables.

// This is technique one, using editor_seq() or editor_frame().
// This approach is documented in the DINKC Reference v3.1 text file and the
// DinkC Reference v4.0 MSwindoze help file. According to ManaUser, this
// techique works as long as editor_type() is 0.
//
// If you know the editor number of the sprite, then you can hard code
// it instead of using sp_editor_num() to find out what it is. But be
// careful... if you move things around, add and subtract many sprites
// in the screen, the editor number could change.
void main( void )
{
int &edtnum = 0;
int &been_here = 0;
&edtnum = sp_editor_num(&current_sprite);
&been_here = editor_seq(&edtnum, -1);
if (&been_here == 0)
{
// Do stuff here.
//
// Make certain we don't do it again next time we enter this screen.
editor_seq(&edtnum, 1);
}
}

Another method that allows you to have things work no matter what screen you are on, is to store more than one on/off value in one integer. A way of doing that is to use my checkbit.c technique. This is only worth the effort to set up and use if you
a) want to stop doing something in one screen based on something that happens in another screen.
AND/OR
b) find yourself adding more than 5 global variables to control the on/off status of various game elements.
You can download a zip file that contains, demonstrates and explains checkbit.c from the development area of the DN. You can also see it at work in several of the dmods I have uploaded to the DN.

// To use this method, you need to add two global variables as globals,
// which will give you 62 on/off Boolean variables to use as you see fit.
// If you need to check the value more than once in a script, you can assign a
// variable from the &return variable (*right away* *as* *soon* *as* *code*
// *execution* *returns* *from* *checkbit.c*) instead of using &return
// (*right away* *as* *soon* *as* *code* *execution* *returns* *from*
// *checkbit.c*) in an if/then block.
//
// I find it helpful to keep a text file around explaining what each of
// the values is used for AND to comment the use of each invocation of
// checkbit.c in the code.

void main( void )
{
// Dink finds a trapdoor.
external("checkbit", "main", 134217728, -1, 1);
if (&return == 0)
{
say_stop("<Hmmm> I think I should examine this trapdoor carefully.", 1);
// Dink finds a trapdoor.
external("checkbit", "main", 134217728, 1, 1);
}
}