The Dink Network

Reply to Re: wait_for_bottom

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:
 
 
May 2nd 2014, 02:06 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I'll just go pimp run_script_by_number() again. If you put &current_script somewhere in a global, you can use that in a key script to jump to a procedure.

It's a bit of a roundabout way of doing things, though. Still, it may be of some use in some cases.

// somewhere in main.c
  make_global_int("&keyhandler",0);

// key-68.c
void main( void )
{
  if (&keyhandler > 0)
  {
    run_script_by_number(&keyhandler,"d");
  }
  kill_this_task();
}

// script.c
void main( void )
{
  int &d = 0;
}

void talk( void )
{
  if (&d > 0)
  {
    say_stop("Nope. Wrong button. Press D.",1);
    return;
  }

  say_stop("Oh. Looks like I have to press D to continue.",1);
  &keyhandler = &current_script;
  return;
d1:
  say_stop("Another bit of stuff here.",1);
  say_stop("Mind, you, to see more, press D again.",1);
  &keyhandler = &current_script;
  return;
d2:
  say_stop("That's it! Keep pressing that key!",1);
  &keyhandler = &current_script;
  return;
d3:
  say_stop("End of story.",1);
}

// I'm not too happy about this bit, but oh well. You could of course put the cutscene-stuff directly inside this.
void d( void )
{
  &keyhandler = 0;
  &d += 1;
  if (&d == 1)
  {
    goto d1;
  }
  if (&d == 2)
  {
    goto d2;
  }
  if (&d == 3)
  {
    goto d3;
  }
}


Also works great with spawn():

// In main.c
  make_global_int("&keyhandler",0);
  // Did you know: main.c gets run on game load as well!
  &keyhandler = spawn("keyhandler");

// keyhandler.c
void d( void )
{
  say("D",1);
}

// key-68.c
void main( void )
{
  if (&keyhandler > 0)
  {
    run_script_by_number(&keyhandler,"d");
  }
  kill_this_task();
}