The Dink Network

Reply to Re: Hold

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 3rd 2009, 07:48 AM
spike.gif
The bold part. More specificly,
editor_seq(&mahnum,1);
changes the value of the rock's editor sequence, and
int &mahseq = editor_seq(&mahnum,-1)
if (&mahseq == 1)
checks what that value is.
int &mahnum = sp_editor_num(&current_sprite);
is needed for both being able to see what the value of editor_seq is, and being able to change it reliably. Since editor_seq is changed when the player pushes the rock, by checking the value of editor_seq at the beginning of the script, we can tell whether the player has moved the rock before or not.

It's a few extra lines of complication and confusement, but the benfit is that you don't waste a global on something that really doesn't need it (all in all, you can only have about 200 different global variables- not to even mention how totally nasty clogging main.c with unnecessary globals looks like ).

Using a global variable works just as well, (&story = 5; changes the value, if (&story == 5) checks what that value is), you just have to declare the global first. In that example, the declaration line would be:
make_global_int("&story",0);
All the globals are usually declared in a dmod's main.c script. Check it out!

PS. Not sure whether that cleared anything up or just made it sound more complicated. Feel free to ask as many questions as you want, but reading some tutorials (the dinkC reference and metatarasal's introduction to dmod making are good ones to start with) would be a very good idea, too, especially concerning global variables and if statements and such; it's... pretty basic stuff, and the tutorials give a much broader overview and understanding of DinkC than answers to specific questions here on the board.