save_x and save_y
FIFO & Variables in DinkC
can anyone explain to me exactly what you need to do with emake.c in order to delete the save_x and save_y globals? there arent really any instructions that i can understand im pretty much confused as to what the author is talking about, other than that its a good file but any clarification please?
You can use ¤t_sprite in emake.c because it's called using external() from a script that is attached to a sprite, so using globals is unnecessary.
Basically, think of emake.c as if it is attached to the sprite that just died.
Instead of carrying the x & y positions across in globals, just put sp_x(¤t_sprite, -1); in emake.c instead of in the sprite's script and it will work.
Hope that makes sense
Basically, think of emake.c as if it is attached to the sprite that just died.
Instead of carrying the x & y positions across in globals, just put sp_x(¤t_sprite, -1); in emake.c instead of in the sprite's script and it will work.
Hope that makes sense

so just adding int &save_x = sp_x(¤t_sprite); at the top of emake.c script alone would let you delete &save_x global, right?
Yes I suppose so, if emake.c really is the only script that uses them. And you'd need to do it at the top of each procedure (medium, large etc), not just once for the whole script.
I'm not sure using ¤t_sprite in the external script would work, but you can carry over variables from the original script to the external script if it doesn't. I think you can carry over up to 8 variables this way.
//for the main script
int &this_x = sp_x(¤t_sprite,-1);
int &this_y = sp_y(¤t_sprite,-1);
external("emake","small",&this_x,&this_y);
//for the emake.c script
int &save_x = &arg1;
int &save_y = &arg2;
Edit: After testing I see that ¤t_sprite does in fact work with external (just as sparrowhawk said) so just ignore this post
//for the main script
int &this_x = sp_x(¤t_sprite,-1);
int &this_y = sp_y(¤t_sprite,-1);
external("emake","small",&this_x,&this_y);
//for the emake.c script
int &save_x = &arg1;
int &save_y = &arg2;
Edit: After testing I see that ¤t_sprite does in fact work with external (just as sparrowhawk said) so just ignore this post

Yeah the tutorial is unclear in several parts.. but Sparrowhawk does know what I meant there.
It's a little funny that Seth went to so much trouble putting two lines in every enemy script and reserving two globals in order to save the position information across the transfer from the enemy script to emake... when really the transfer is a bit of an illusion and that information isn't lost in the first place. Calling a script with external() will use the same script number and that's all dink.exe cares about (not the script name).. hence why ¤t_sprite still works.
So:
put
int &save_x = sp_x(¤t_sprite,-1);
int &save_y ...
at top of each emake function (small, medium, large I think they are called)
and you can del &save_x and &save_y.. you should also delete the 2 lines which involve &save_x/y from each enemy script die procedure.
Also, from memory, the newer versions of Prophecy of the Ancients don't have &save_x/y. Nexis used the (less efficient) strategy rabidwolf detailed in this thread. So that proves you can delete those variables (i.e. there are no internal calls to them, as that would crash dink.exe).
It's a little funny that Seth went to so much trouble putting two lines in every enemy script and reserving two globals in order to save the position information across the transfer from the enemy script to emake... when really the transfer is a bit of an illusion and that information isn't lost in the first place. Calling a script with external() will use the same script number and that's all dink.exe cares about (not the script name).. hence why ¤t_sprite still works.
So:
put
int &save_x = sp_x(¤t_sprite,-1);
int &save_y ...
at top of each emake function (small, medium, large I think they are called)
and you can del &save_x and &save_y.. you should also delete the 2 lines which involve &save_x/y from each enemy script die procedure.
Also, from memory, the newer versions of Prophecy of the Ancients don't have &save_x/y. Nexis used the (less efficient) strategy rabidwolf detailed in this thread. So that proves you can delete those variables (i.e. there are no internal calls to them, as that would crash dink.exe).