The Dink Network

The int &crap part

October 27th 2003, 08:08 AM
duck.gif
I've always wondered what the int &crap part means Can someone please tell me? Thanks
October 27th 2003, 08:20 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
int &crap;

means you create a local variable which can hold a value which you can use in that script. For example:

int &crap = 5;
//&crap = 5
int &crap = &story;
//&crap = the value of the variable story
int &crap = sp(13);
//&crap = the in-game value of editorsprite 13
int &crap = save_x(1, -1);
//&crap = value of x-coordinate of Dink

Take note that it's a local variable and can therefore only be used in that script. If you want a variable that can be used in various scripts, make a global one. Place a line like this in main.c:

make_global_int("&var", 0);

where &var is the name of the variable. Using &crap or &junk as a global isn't a good idea because various scripts already use those variables as locals.
October 27th 2003, 10:45 AM
duck.gif
hey, thanks, it finally makes some point!
October 27th 2003, 11:52 AM
wizardg.gif
Paul
Peasant He/Him United States
 
Not that we mind answeing questions, but let me point you to a very good refernce for this stuff:
DinkC Reference v3.1 by Ted Shutes
It's in the Development files section.

It's a HUGE file but you can find what you need fast by using the search command. And if you put a # before what you search for (eg #int) it will take you right to the main description of that command.
October 27th 2003, 12:01 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Hehe, here's the link, Paul .
October 27th 2003, 02:22 PM
duck.gif
Ok, thanks.... I guess i do need it
I don't wanna be a pain in the butt, I understand what ya mean, no hard feelings ....
October 27th 2003, 05:06 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
About local variables. I have found these aren't read by custom procedures (unless created in the custom procedure itself)

ie - in a sample trader script which is usually attached to a bench and generates a trade dude which he shall call &trader so he talks to Dink instead of the bench... then if you create a custom procedure - say like "getDinkDrunk()" then the &trader variable doesn't seem to be recognised.

I got around this by using the tempholder global variables that the original game uses - &temphold, &temp1hold... etc
October 27th 2003, 07:06 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
There is a way to pass variables to procedures... but it is quite weird, and difficult to explain. I used (and documented) the technique in Initiation, which I should finish someday.