The Dink Network

Reply to Re: sp_custom

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:
 
 
July 13th 2006, 09:23 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
sp_custom does support unlimited attributes. It uses dynamic memory allocation to get the job done. Granted, if you try to store a billion of the buggers, I'm not sure how well that would work.

As for how to store lots of values... I've had an idea for quite a while. I haven't used it a lot, but it works. Be sure to read the warnings at the end.

In Dink (all versions), the only easily accessible persistant data is global variables and editor sprite information. There's plenty of other information (item scripts, various variables, etc.), but it really isn't very useful or accessible.

So... you have 248 globals (integers), 76032 (99 sprite * 768 screens) editor frames (bytes, range 0-255), and 76032 editor sequences (shorts, range 0-65535). Hey... there's a lot of editor frames and sequences, aren't there?

We can *easily* access all of them. I suggest taking advantage of the custom procedures in Dink 1.08. Try this script:

//function.c
void super_editor_seq( void )
{
//Arguments: &arg1 = map (1-768), &arg2 = sprite (1-99), &arg3 = value (-1 to return)
//NOTE: value must be in range 0-65535 due to memory limitations.
int &old_map = &player_map;
&player_map = &arg1;
int &value = editor_seq(&arg2, &arg3);
&player_map = &old_map;
return(&value);
}

Then insert this in main.c:

//main.c
make_global_function("function", "super_editor_seq");

And then, in theory, you could use it like this:

//somescript.c
void main(void)
{
// set the value of the '768-1' editor variable to 45
super_editor_seq(768, 1, 45);
}

//anotherscript.c
void main(void)
{
// get the value of the '768-1' editor variable
super_editor_seq(768, 1, -1);
int &my_value = &return;
say("&my_value", 1);
//We could also just do say("&return", 1); but then we couldn't access the value after that
}

Bam. You now have 'easy' access to 76,032 more values. You just have to remember the map-sprite key (probably a good idea to write it down somewhere). And if you want even more values, you could create a super_editor_frame function too.

Now... for the bad news. You can't use all 76,032 values. The editor_seq and editor_frame data is used in conjunction with editor_type so barrels can stay broken and the like. It is highly recommended that you only use screen numbers for empty screens.

If you plan on using every screen on the map, then your options are a bit more limited. Most screens don't use all 99 sprites, so you should be able to access sprite 99 data for all 768 maps without too much trouble.

Even if you use all 99 sprites on each screen, you could try to keep track of which sprites could have editor_types of 2, 3, 4, and 5. That includes boxes, chests, burnable trees, etc. Also watch out for sprites with scripts that use Paul's Script Trick (which also abuse editor_seq and editor_frame).

And if decide to make all 99 sprites for each screen a breakable barrel... well, then I think your D-Mod has some serious gameplay issues.