The Dink Network

Some problem

December 4th 2005, 03:27 PM
bonca.gif
Erwin
Peasant He/Him Netherlands
Friendship is magic 
I'm trying to blow up some rocks in this script but it doesn't work. Can someone tell me what I'm doing wrong.

void main (void)
if (&story == 4)
{
freeze(1);
int &rock1 = sp(1);
int &rock2 = sp(2);
int &rock3 = sp(3);
int &rock4 = sp(4);
int &rock5 = sp(5);
int &rock6 = sp(6);
int &rock7 = sp(7);
int &rock8 = sp(8);
int &rock9 = sp(9);
int &rock10 = sp(10);
int &newsprite = create_sprite(300, 100, 0, 373, 1);
sp_seq(&newsprite, 373);
sp_speed(&newsprite, 2);
sp_timing(&newsprite, 0);
sp_base_walk(&newsprite, 390);
say_stop("`0OK the explosives are set.", &newsprite);
wait(200)
say_stop("`0Take cover!", &newsprite);
wait(200)
move_stop(&newsprite, 8, 50, 1);
wait(200)
move_stop(1, 8, 100, 1);
wait(200)
int &bomb = create_sprite(425, 175, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
int &bomb = create_sprite(425, 250, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
int &bomb = create_sprite(500, 200, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
sp_hard(&rock1, 1);
draw_hard_map(&rock1);
int &hold = sp_editor_num(&rock1);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock1, 0);
sp_hard(&rock2, 1);
draw_hard_map(&rock2);
int &hold = sp_editor_num(&rock2);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock2, 0);
sp_hard(&rock3, 1);
draw_hard_map(&rock3);
int &hold = sp_editor_num(&rock3);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock3, 0);
sp_hard(&rock4, 1);
draw_hard_map(&rock4);
int &hold = sp_editor_num(&rock4);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock4, 0);
sp_hard(&rock5, 1);
draw_hard_map(&rock5);
int &hold = sp_editor_num(&rock5);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock5, 0);
sp_hard(&rock6, 1);
draw_hard_map(&rock6);
int &hold = sp_editor_num(&rock6);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock6, 0);
sp_hard(&rock7, 1);
draw_hard_map(&rock7);
int &hold = sp_editor_num(&rock7);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock7, 0);
sp_hard(&rock8, 1);
draw_hard_map(&rock8);
int &hold = sp_editor_num(&rock8);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock8, 0);
sp_hard(&rock9, 1);
draw_hard_map(&rock9);
int &hold = sp_editor_num(&rock9);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock9, 0);
sp_hard(&rock10, 1);
draw_hard_map(&rock10);
int &hold = sp_editor_num(&rock10);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock10, 0);

wait(500)
say_stop("`0You can go now if you want.", &newsprite);
wait(200)
say_stop("`0I'm going back home now.", &newsprite);
wait(200)
say_stop("`0By the way, you can keep the knife you need it more than I do.", &newsprite);
wait(300)
say_stop("`0Bye.", &newsprite);
wait(200)
say_stop("Bye.",1);
wait(200)
move_stop(&newsprite, 8, -50, 1);
wait(300)
&story = 5
unfreeze(1);
December 4th 2005, 03:36 PM
dragon.gif
Umm, you appear to be missing a } at the end of it. Without that it won't work.
December 4th 2005, 03:40 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
int &rock1 = sp(1);
sprite 1 is always dink;
Usually, the sprite number you see in the editor is not the real one, because dink is not there. Probably, if you see 1 in the editor, your sprite will be 2.
I don't know if it's the best ideea, but you could attach a script to every rock, with this:
void main(void)
{
sp_brain(&current_sprite, 91);
}

the secon rock would have:

void main(void)
{
sp_brain(&current_sprite, 92);
}

Then, in your main script
&rock1 = get_sprite_with_this_brain(91, &current_sprite);
&rock2 = get_sprite_with_this_brain(92, &current_sprite);
December 4th 2005, 04:00 PM
dragon.gif
Oh, yes. I didn't spot that one. But you're quite right 1 is reserved for Dink.
December 4th 2005, 04:00 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Sprite 1 is always Dink, yes, but sp(1) is not. sp(1) is the sprite number of editor sprite 1. Since Dink doesn't exist in the editor, sp(1) is not Dink. In other words: sp_editor_num(1) doesn't exist, so probably returns 0 or -1.
December 4th 2005, 04:29 PM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
Eh, just do what I do and avoid using sp() and sp_editor_num() for retrieving sprites #'s whenever possible... it saves you a lot of possible confusion in future editing.
December 4th 2005, 04:56 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I do it like that too, except that sp_editor_num() is useful for what's known as "Paul's Script Trick".
December 4th 2005, 05:36 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Yeah... sp_editor_num is good, but the valid uses for sp are quite limited.
December 5th 2005, 11:47 AM
bonca.gif
Erwin
Peasant He/Him Netherlands
Friendship is magic 
I still can't get it working. Cypry what exactly do you mean. I've tried what you said but it doesn't work. I must be doing something wrong. By the way do you mean with main script MAIN.c or the script shown on above?
December 5th 2005, 12:14 PM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
Hi Erwin, and sorry to Cypry for butting in.

Line 4 of your script you have assigned
&rock1 = sp(1), but this is usually Dink. Not always apparently, but it should be. If you select this rock in dinkedit, the info at the bottom should give you the sprite_editor_num() which is different from sp().

&rock1 = sprite_editor_num(x)

I think what Cypry is saying is to write a script that deals only with blowing up a rock. Then you can call it from this screen script, and use &current_sprite as each rock blows up.

hth,
mm.
December 5th 2005, 01:07 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Wrong again.

sp(1) returns the value used by scripts, and needs the value as it appears in the editor. In this case 1 is the sp_editor_num.

sp_editor_num(sp(&crap)) = &crap;
sp(sp_editor_num(&crap)) = &crap;

consider &sprite a sprite put on the screen in the editor, then

&crap = sp_editor_num(&sprite);
say_stop("hey", &crap);

will probably result in another sprite than &sprite saying "hey"

&crap = sp(&sprite)
say_stop("hey", &crap);

will work.

Now say &sprite is placed with create_sprite() in the same script as the following lines:

&crap = sp_editor_num(&sprite);
say_stop("hey", &crap);

Will result in no text at all (or something equally buggy) as &sprite doesn't exist in the editor, so sp_editor_num() doesn't exist (so returns 0 or -1)

&crap = sp(&sprite);
say_stop("hey", &crap);

will make no sense, as sp() needs an editor number as input, and &sprite doesn't exist in the editor.

The correct way to do it with create_sprite() is:

say_stop("hey", &sprite);

Best is not to bother with sp() at all (sp_editor_num() is used for an advanced trick). Use &crap = create_sprite() or possibly the global variable thing (by adding a script whith &store = &current_sprite;, &store is a global, to the sprite) to interact with different sprites than Dink or &current_sprite.
December 5th 2005, 02:11 PM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
I am not well versed in DinkC so I will neither argue nor accept that sp_editor_num() and sp() are automatically the same entity without researching same.

sp_editor_num is tagged at design time, whereas I assume that sp() is assigned at script run time. If I have this wrong, please inform.

You seem to have some good advice here but I am still not convinced that
sp_editor_num(x) = sp(x).

In lines 3-4 of your reply, are you suggesting that we can reassign the editor_num at run time or was this simply a comparison to show that the 2 may be the same entity?

Nitpick: Line 5; Which one?
&sprite would either be undefined or sp(0), which cannot speak.

Irregardless, it would seem prudent to have a separate script for the "blowing up of the rocks" rather than diluting it into the screen script.

mm
December 5th 2005, 04:42 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
You seem to have some good advice here but I am still not convinced that
sp_editor_num(x) = sp(x).


That's because they aren't. If you pardon the somewhat mathematical term, they're each other's inverse.

I'll try to explain it as well as I can, but it's rather difficult if you feel the difference intuitively, as you might know.
Anyway, here I go:

In dinkedit (or WDE, of course), attach the script test.c to a sprite you've placed there. Write down the number just before you save and exit the program.

test.c looks like this:

void main( void )
{
int &crap = sp(###written number###);
if (&crap == &current_sprite)
{
say_stop("Okay, so sp() transforms the 'editor number' into a 'script number'", 1);
say_stop("`5 That's true, Dink, and you can use it in say_stop lines, move lines, ",&crap);
say_stop("`5 and other script commands that need a sprite number", &crap);
}
else
{
say_stop("Make sure you've written down the 'editor number' after you've done all other modifications",1);
}
wait(500);
&crap = sp_editor_num(&current_sprite);
if (&crap == ###written number###)
{
say_stop("Okay, so sp_editor_num() transforms the 'script number' into a 'editor number'", 1);
say_stop("`5 That's true, Dink, and as you see, using this 'editor number' in scripts", &crap);
say_stop("`5 can lead to weird behaviour", &crap);
say_stop_xy("`% Note that if the correct sprite is talking",1,1);
say_stop_xy("`% try to place more sprites on the screen with the editor",1,1);
say_stop_xy("`% don't forget to update the number you wrote down in the script",1,1);
}
else
{
say_stop("Make sure you've written down the 'editor number' after you've done all other modifications",1);
}
}

I hope this makes sense, if not, I hope someone else can explain better, or perhaps explain it to me
December 5th 2005, 05:03 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Man o' Magic wasn't saying that sp_editor_num(x) = sp(x)... he was saying (put in a valid, DinkC way):

int &editor_sprite1 = 1;
int &active_sprite = sp(&editor_sprite1);
int &editor_sprite2 = sp_editor_num(&active_sprite);
if (&editor_sprite1 == &editor_sprite2)
{
say("They're always equal (unless it doesn't exist)!", 1);
}

That is:

sp_editor_num converts an active sprite number into an editor sprite number.

sp converts an editor sprite number into an active sprite number.

Therefore, if sp_editor_num uses the output of sp as an input, it will result in the input of sp, assuming the editor sprite and the active sprite exist.

All Dink functions (with the exception of editor_seq, editor_frame, and editor_type) use active sprite numbers.

The only valid use of sp is to look in DinkEdit or WinDinkedit, record the editor sprite number of a sprite, and use it as an input in sp to get the active sprite number. However, because editor sprite numbers are apt to change (at least with WinDinkedit), this isn't recommended.
December 5th 2005, 05:06 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Magicman: my reply came a bit after yours (I was viewing a cached version of the page, d'oh), but yours is mostly correct. The only potentially confusing thing is your use of the term 'script numbers'... each active instance of a script has its own number as well (using &current_script, is_script_attached(), and run_script_by_number()), and those are generally called script numbers.

I've taken to calling them active sprites or active sprite numbers to avoid any confusion.
December 5th 2005, 05:07 PM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
Yes, I think the 3 of us are saying the same thing but taking offense to the minor points of the other posts.

sp_editor_num() is defined in the editor.
sp() is defined in the script.

imho, a screen script should deal with things unique to that screen. Typical potions are handled with a single script throughout the game, perhaps these rocks should be handled in the same way.

mm
December 5th 2005, 05:10 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
sp_editor_num() returns an editor sprite number, which is defined in the editor.

sp() returns an active sprite number, which is defined at run-time.

To say the functions themselves are defined in one or the other is a bit... odd.
December 5th 2005, 05:45 PM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
December 5th, 02:11 PM
I am not well versed in DinkC so I will neither argue nor accept that sp_editor_num() and sp() are automatically the same entity without researching same.

sp_editor_num is tagged at design time, whereas I assume that sp() is assigned at script run time. If I have this wrong, please inform.

As per my post earlier in the thread, I agree.
I also agree that I am in general a bit odd and I should not allow my own nits to be pickable. (is that a word?)

I should have said
return(sp(x)) where x is defined at run-time.
mm

December 6th 2005, 01:58 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
or possibly the global variable thing (by adding a script whith &store = &current_sprite;
My ideea, for not wasting space with global vars was the following:
For each rock, do the following script:
-for rock 1:
void main(void)
{
sp_brain(&current_sprite, 91);
}

-for rock 2:
void main(void)
{
sp_brain(&current_sprite, 92);
}

for rock 3:
void main(void)
{
sp_brain(&current_sprite, 93);
}

Notice that I attached to every rock a different brain, that doesn't make the sprite move/change seq, and most important, that sprite is the single sprite with that brain on the screen. Then, in the procedure that makes the explosion, I enter:
int &rock1 = get_sprite_with_this_brain(91, &current_sprite);
int &rock2 = get_sprite_with_this_brain(92, &current_sprite);
and so on...
Then, you can use those variables to call the sprites.
I repeat, I don't know if it's the best ideea, but it always worked and I never had problems with it.
December 6th 2005, 02:03 PM
spike.gif
That's a nice way to do it... No point in making a script for each rock though, just set the brain in the editor.
December 6th 2005, 02:07 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
No point in making a script for each rock though, just set the brain in the editor
I use WinDinkEdit, because I'm too lazy to use DinkEdit, and WinDinkEdit don't let me set another brain than the common ones.
December 6th 2005, 02:09 PM
spike.gif
However, because editor sprite numbers are apt to change (at least with WinDinkedit), this isn't recommended.

Mwahaha, feeble windinkedit. ( ) I don't think I've ever had trouble with them changing.
December 6th 2005, 05:36 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Give them the same script, but a different unused stat (eg strength, defense), and add the following script:

void main( void )
{
int &crap = sp_defense(&current_sprite, -1);
sp_brain(&current_sprite, &crap);
}

or sp_strength instead of sp_defense, depends on what you're using.
December 6th 2005, 08:57 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Erwin, sorry for threadjacking your question about blowing up rocks with bombs... I'm creating a video tutorial that will show you a nice way to do it.
December 7th 2005, 01:40 PM
bonca.gif
Erwin
Peasant He/Him Netherlands
Friendship is magic 
I've finaly fixed it. I just did this:
void main (void)
{
if (&story < 5)
{
int &rock1 = create_sprite(416, 178, 0, 95, 10);
int &rock2 = create_sprite(414, 199, 0, 95, 8);
int &rock3 = create_sprite(477, 211, 0, 95, 3);
int &rock4 = create_sprite(473, 231, 0, 95, 6);
int &rock5 = create_sprite(459, 251, 0, 95, 2);
int &rock6 = create_sprite(435, 257, 0, 95, 9);
int &rock7 = create_sprite(432, 286, 0, 95, 4);
int &rock8 = create_sprite(418, 313, 0, 95, 1);
int &rock9 = create_sprite(518, 235, 0, 95, 5);
int &rock10 = create_sprite(557, 237, 0, 95, 7);
sp_hard(&rock1, 0);
draw_hard_map(&rock1);
sp_hard(&rock2, 0);
draw_hard_map(&rock2);
sp_hard(&rock3, 0);
draw_hard_map(&rock3);
sp_hard(&rock4, 0);
draw_hard_map(&rock4);
sp_hard(&rock5, 0);
draw_hard_map(&rock5);
sp_hard(&rock6, 0);
draw_hard_map(&rock6);
sp_hard(&rock7, 0);
draw_hard_map(&rock7);
sp_hard(&rock8, 0);
draw_hard_map(&rock8);
sp_hard(&rock9, 0);
draw_hard_map(&rock9);
sp_hard(&rock10, 0);
draw_hard_map(&rock10);
}
if (&story == 4)
{
freeze(1);
int &newsprite = create_sprite(300, 100, 0, 373, 1);
sp_seq(&newsprite, 373);
sp_speed(&newsprite, 2);
sp_timing(&newsprite, 0);
sp_base_walk(&newsprite, 390);
say_stop("`0OK the explosives are set.", &newsprite);
wait(200)
say_stop("`0Take cover!", &newsprite);
wait(200)
move_stop(&newsprite, 8, 50, 1);
wait(200)
move_stop(1, 8, 100, 1);
wait(200)
int &bomb = create_sprite(425, 175, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
int &bomb = create_sprite(425, 250, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
int &bomb = create_sprite(500, 200, 7,161,1);
sp_seq(&bomb, 161);
playsound(6, 22050, 0,0,0);
sp_hard(&rock1, 1);
draw_hard_map(&rock1);
int &hold = sp_editor_num(&rock1);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock1, 0);
sp_hard(&rock2, 1);
draw_hard_map(&rock2);
int &hold = sp_editor_num(&rock2);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock2, 0);
sp_hard(&rock3, 1);
draw_hard_map(&rock3);
int &hold = sp_editor_num(&rock3);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock3, 0);
sp_hard(&rock4, 1);
draw_hard_map(&rock4);
int &hold = sp_editor_num(&rock4);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock4, 0);
sp_hard(&rock5, 1);
draw_hard_map(&rock5);
int &hold = sp_editor_num(&rock5);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock5, 0);
sp_hard(&rock6, 1);
draw_hard_map(&rock6);
int &hold = sp_editor_num(&rock6);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock6, 0);
sp_hard(&rock7, 1);
draw_hard_map(&rock7);
int &hold = sp_editor_num(&rock7);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock7, 0);
sp_hard(&rock8, 1);
draw_hard_map(&rock8);
int &hold = sp_editor_num(&rock8);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock8, 0);
sp_hard(&rock9, 1);
draw_hard_map(&rock9);
int &hold = sp_editor_num(&rock9);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock9, 0);
sp_hard(&rock10, 1);
draw_hard_map(&rock10);
int &hold = sp_editor_num(&rock10);
if (&hold != 0)
{
//this was placed by the editor, lets make the barrel stay flat
editor_type(&hold, 1);
}
sp_active(&rock10, 0);

wait(500)
say_stop("`0You can go now if you want.", &newsprite);
wait(200)
say_stop("`0I'm going back home now.", &newsprite);
wait(200)
say_stop("`0By the way, you can keep the knife you need it more than I do.", &newsprite);
wait(300)
say_stop("`0Bye.", &newsprite);
wait(200)
say_stop("Bye.",1);
wait(200)
move_stop(&newsprite, 8, -50, 1);
wait(300)
&story = 5
unfreeze(1);
}

if (&story > 5)
{
}

}

so it's simple enough.