The Dink Network

Ineracting sprites

January 24th 2014, 05:19 PM
dragon.gif
Quiztis
Peasant He/Him Sweden bloop
Life? What's that? Can I download it?! 
Yo, it's me again with a question:

I create a sprite with a script, say gold500.

When Dink does something like punching a different sprite with a different script, is there any way of changing the gold's frame via that scripts void (hit)?

I found examples and know how to change the frame, but not when there are two different scripts.
January 24th 2014, 05:42 PM
wizardg.gif
Sure. I'd do it by giving the gold a unique brain- say 49.
Then in the hit procedure of the different sprite run &variable = get_rand_sprite_with_this_brain(49, 0);
sp_pframe(&variable, newframe);

That should work.
If you use get_sprite_with_this_brain() without a variable I'm unsure whether or not it will return a value in &result.
January 24th 2014, 05:52 PM
peasantm.gif
shevek
Peasant They/Them Netherlands
Never be afraid to ask, but don't demand an answer 
Yes, no problem at all. What you need is the sprite number. Then you can just use that in sp_frame.

Getting the sprite number may be done in several ways. If your sprite doesn't need a special brain, you can use that as was suggested. If it does, then you can use the target sprite's main function to store its ¤t_sprite into a global, which you then use in your other script.

Finally, what I would do, is use sp() on the editor number of the sprite. However, this requires you to know the editor number, and I'm not sure how constant that is with other editors. In my editor, it is not constant at all, but I can refer to the sprite by name, and it will fill in whatever editor number it has generated for it (as in sp_frame (sp ("chest"), 4); ) . AFAIK in other editors doing something similar would be very fragile, but I might be wrong about that. Actually, I'm sure that in regular dinkedit it would work fine; it will not rearrange the sprite editor numbers, so it isn't fragile at all; just unreadable. But that's DinkC for you.
January 24th 2014, 05:57 PM
dragon.gif
Quiztis
Peasant He/Him Sweden bloop
Life? What's that? Can I download it?! 
Yeah, I was also thinking slightly along those lines, thanks.