The Dink Network

A script that runs on launch(but not on restart_game)

February 24th 2022, 05:15 PM
Jester Male Australia
You feed the madness, and it feeds on you. 
Turns out you can make a game launch detection script, it will run everytime the game is launched, but NOT on restart_game(); (such as when returning to the title screen).
I found out that restart_game() re-initialises dink.ini, but will ignore giving any sprite the crappy default hardbox (which is usually given when no sprite info is specified in dink.ini), if you do it through "init" AFTER launch but BEFORE restart_game() is called.

So here's a script that only runs each time the game is launched and at no other time:
create a sprite, doesn't matter what, just a blank square of any size (can just tack 1 extra frame onto any sequence for this). Don't set any "set_sprite_info" information in dink.ini, let it initialize the inaccurate default hardbox. In this example, the extra sprite is sequence 64, frame 14.

put this in start.c, after all the load_sounds lines:
  //detect game launch
  int &dstart = create_sprite(1, 1, 14, 64, 14);
  sp_script(&dstart, "onlaunch");
  &crap = sp_custom("startup", &dstart, -1);
  if (&crap > 0)
   init("SET_SPRITE_INFO 64 14 24 25 -114 -108 -97 -89");
   say("this will run only on game launch", 1);
   sp_active(&dstart, 0);

The onlaunch script that gets attached to the sprite is this:
void buttonon(void)
 sp_custom("startup", &current_sprite, 1);

How it works:
When the game starts up, dink.ini is loaded and no sprite info is found for sequence 64, frame 14, so it gives it the crappy default hardbox. That sprite is created at x: 1, y: 1, which is the default starting position of sprite 1 (Dink, or the mouse when the game starts), so the mouse is forced on top of it, triggering the buttonon procedure of onluanch.c. This sets an sp_custom value on the created sprite, which is then immediately checked by start.c and if set, runs the code.
Here's the cool thing of why it only works on launch, when the code is run, we run a init command which runs a set_sprite_info line to change the hardbox. This will even survive through a restart_game() command. For some reason, even though the dink.ini is re-initialized on a restart_game, it won't give the default hardbox to sprites without info, if they've been given one through init BEFORE restart_game() was called.
February 25th 2022, 12:41 AM
Peasant Male Equatorial Guinea xbox steam duck bloop
can't flim flam the glim glam 
finally, we can play overblown cgi intros for our dmods
February 25th 2022, 03:01 PM
Jester Male Australia
You feed the madness, and it feeds on you. 
Actually I think Magicman used a similar technique to this to get some of the stuff in "WAITWUT" to work.

Although in my testing init lines didn't carry across after restart_game(), if there was a set_sprite_info like for the frame in dink.ini... the dink.ini line would take priority.