The Dink Network

Re: D-Modding tips 'n tricks

March 13th 2010, 10:04 PM
dinkdead.gif
I've collected together a bunch of random useful tips and things while learning D-Modding, scripting, mapping etc. I did think recently of releasing it as a 'helpful file' but think it would be better here, partly because I'm not so sure of it's usefulness ( ) and partly so others can add their own tips & tricks to the discussion, or correct mine.

Some I worked out myself, some are in the DinkC Reference, some both... They could all be really obvious to everyone else for all I know, especially anyone who knows anything about programming rules (I only know DinkC)
Anyway, here it is.

DinkC =============================================

- I wanted to use &bloody_duck_is_dead_at_last as a local variable but it was too long.
So I checked and the max size of a variable (local or global) is 18 characters, not including the ampersand (&).
eg: &helloandgoodmorning won't work
but: &helloandgoodmornin will work.

Not including the colon (: ) , the max size of a goto label is 107 characters! So you could use whole sentences if you like.

With both of those it may be better to keep them shorter 'just in case', but I didn't have any problems while testing.

- You can't use variables as goto labels - whatever the label is it will go to.
int &test = 15;
goto &test;
15:

the script will stop executing because it can't find '&test' to go to.

goto &test;
&test:

it will go to &test whether it is a variable or not.

Many symbols are ok to use also, I tested *+-^$%&"<>?! and they work fine so I presume any ASCII symbol will work, but I wouldn't try ";" ":" etc for obvious reasons. They are fine in variables too according to the DinkC Ref.

- sp_clip_top/bottom/left/right works oddly. You need to clip a bit in the editor before they'll work, or set where the clipping starts from first. See this thread.

- You can use variables for colour codes. For example:
int &col = random(9, 1);
say("`&col Wheee!", &sprite);

will say 'Wheee!' in a random colour.
You don't actually need to put a space between the variable and the rest of the text, but it makes it easier to read when you're looking at the scripts.
say("`&colWheee!", &sprite);

will work just the same.

- Colour code 14 (`$) is the default colour that Dink normally uses, if you're interested in changing it or whatever.

- If you use sp_blood_seq you have to put sp_blood_num as well or it won't work, and vice-versa. Just use the default for the one you haven't changed.

- If nohit is set to 1 the hit procedure will still be called. Why would you want this?
If you want no hit sound to be played and for missiles to pass through but you still want something to happen in a script, for example. I dunno.

- If you create a sprite and have it say something straight away the words will appear at its base.
Stick a wait(1) in between to make it work.
//Hello! will appear at x/y or so and Goodbye! will appear correctly above the sprite unless you stick a wait(1) after the create_sprite.
int &sprite = create_sprite(x, y, blah blah);
say_stop("Hello!", &sprite);
say_stop("Goodbye!", &sprite);


WinDinkEdit+ ==============================================

- Tools > Options > Tile Brush is the size of the brush when editing hardness tiles.

-Clipping sprites: Z is from top left, X is from bottom right.
Select the sprite and don't use ctrl+z, just z.

- The sprite library is a very useful and seemingly little-known tool to store often used sprites. Right click on a sprite and select 'store sprite'. Enter whatever name you like and it will now be under 'sprite library' in the sidebar, just double click on the name to get one - it will remember attributes eg. script, size, nohit, brain, etc. Great for grass, trees and stuff.

Can't think of anything else right now...
March 14th 2010, 01:12 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
- Tools > Options > Tile Brush is the size of the brush when editing hardness tiles.

Sparrowhawk, you officially just became a God.

Or, I've always been an idiot for not knowing that. Editing tile hardness has always been so tedious, but no more!!
March 14th 2010, 04:05 AM
burntree.gif
Fireball5
Peasant He/Him Australia
Let me heat that up for you... 
I knew the tile brush size trick, mostly because I have searched so thoroughly for an option to change the blurring options for the tile hardness editing mode. WDE/+ is good, but I think it really sucks that the tile hardness editor window is so blurred, I can't tell where the actuall edges are and hardness is a few pixels out - which really matters on a game that uses a small 640x480 window.
March 14th 2010, 06:06 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
Oh, NOW YOU'VE DONE IT! 
In WDE, you can hold shift, and click and drag, and you can make a hardness polygon.

I use Notepad++ as my default C editor. I has auto syntax highlighting, and I have recorded a number of macros in it for things like Dink and other sprites talking.

How do you change the colour of $/14?
March 14th 2010, 06:30 AM
goblinh.gif
mkbul
Peasant He/Him Greece
TPA~ 
set_font_color(number, red, green, blue);
March 14th 2010, 07:53 AM
burntree.gif
Fireball5
Peasant He/Him Australia
Let me heat that up for you... 
I have read through the DinkC reference, and noticed that you can do basically anything with colours. It has given me many ideas, yet I'm too lazy to implement them.
March 25th 2010, 08:12 AM
dinkdead.gif
If statements:

if (&var)

is exactly the same as
if (&var != 0)


Also, you don't always need the braces after an if statement. Without braces, the 'if' just applies to the next line, like so:

if (&var)
goto here;
goto there;

If &var is 0 it will go to 'there' and otherwise it will go to 'here'.
You can even do it on the same line!
if (&var) goto here;
goto there;

Not really reccomended though, just indent that line or something.
The exception to this is variables, if you're changing a variable always enclose it in braces even if it's only one line because it has been known to cause problems.
March 25th 2010, 10:04 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
The if statement without brackets doesn't always work. I believe assigning values to variables does not work in that way.
March 25th 2010, 01:07 PM
dinkdead.gif
I mentioned that in the last line
May 2nd 2010, 07:54 PM
dinkdead.gif
More stuff!

You can give things fake brains to keep track of them. For example I needed to keep track of the positions of over 50 sprites, just gave them each a seperate brain number and found them again using get_sprite_with_this_brain.

About using the mouse:

To be able to click something you need to set its touch_damage to -1. Just spent a while getting more and more frustrated with why this wasn't working....
(Edit- this is mentioned in Rabid's mouse help thing, knew I'd seen it somewhere before )

Also, brain 14 is only if you want to use buttonon and/or buttonoff. You can click brain 9 for example just as well.
May 2nd 2010, 08:42 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I was reading through the DinkC reference a week ago and I stumbled upon a note in sp_defense(). It turns out, text sprites use it for their y coordinate relative to the sprite's that is talking. So, we can do this to alter how far the text is above or below NPC or Dink.

//text is drawn 50 pixels above the sprite as opposed to the default 100
say("Funny Text",1);
sp_defense(&return,50);
May 2nd 2010, 08:52 PM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
Sticky? (and add as we go?)
May 3rd 2010, 12:24 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
How exactly does &return; work? Reckon someone give give a quick explanations of the features of that variable? I seem to be unenducated in that department.

"You can give things fake brains to keep track of them. For example I needed to keep track of the positions of over 50 sprites, just gave them each a seperate brain number and found them again using get_sprite_with_this_brain."

How do you mean? You assign each sprite a brain using sp_brain(&sprite, ##)? Wouldn't this cause bad behaviour, though? And does it also work for higher numbers than actual brain numbers?
May 3rd 2010, 01:48 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
Oh, NOW YOU'VE DONE IT! 
Reckon someone give give a quick explanations

Maybe of the English language. Hoho!

You can assign pretty much any number for a brain as there's no limit. It just doesn't do anything like the lower numbered ones do obviously.
May 3rd 2010, 04:19 AM
dinkdead.gif
&return returns the value of the last thing you did, basically... eg, these are identical:
int &sprite = create_sprite(123, 456, 3, 21, 1);
sp_script(&sprite, "duck");

create_sprite(123, 456, 3, 21, 1);
sp_script(&return, "duck");


Useful for things like that but keep in mind it will change for just about anything, so this will not work:
create_sprite(123, 456, 3, 21, 1);
sp_script(&return, "duck");
sp_size(&return, 150);

Because the &return in sp_size is now the script number of duck.c, not any more the sprite number. It would be like this:
int &sprite = create_sprite(123, 456, 3, 21, 1);
&sprite = sp_script(&sprite, "duck");
sp_size(&sprite, 150);


And about the brains, yes what Toasty said. I went up to brain 72 I think, doesn't affect the behaviour. You'd have to use normal brain 9 or something if you needed it to move around etc properly though I'd imagine, not sure.
May 4th 2010, 02:08 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Hey, that's pretty cool about &return.
They say you learn something new everyday.
May 4th 2010, 07:10 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Indeed, I didn't know that either But it does actually explain a few bugs I had in the past where I delayed the use of &return and got wrong values.