Tools: Useful Code Fragments

Tools: Useful Code Fragments

Postby Wahn » Sat Aug 30, 2014 6:16 am

Okay... let's collect useful bits and pieces that can make your life writing for FS a lot easier.

1. [WaitLineBreak]
Text above a certain length should not be hitting the players all at once, to avoid the "ok, not gonna read all that wall of text" reaction. Therefore, a "press any key for more" is good to divide your texts up into more readable chunks. My suggestion is to put one of these lines after every second longer paragraph:

Code: Select all
say "[WaitLineBreak]";


For those interested, what is behind that easy to use little bit is the following function:
Code: Select all
to say WaitLineBreak: [little bit of often used code]
   if waiterhater is 0:
      wait for any key; [skips waiting if it's not wanted]
      if hypernull is 0, say "[line break]"; [adds a break after the 'more']
   otherwise:
      say "[line break]"; [people who don't want to wait at least get a break]      


2. [NavCheck <room name>]
If you are using "instead of navigating to <room name> while (...):" to hijack moving the player and slip an event in, you are also eliminating the checks that the game usually does - if the player is allowed to move in the first place. Therefore you must add these checks back in manually. This is how you do it:

Code: Select all
instead of navigating Grey Abbey Library while (...):
   say "[NavCheck Grey Abbey Library]"; [checks if a move to the named nav point is allowed]
   if NavCheckReturn is false, stop the action; [if it isn't - this move/event is blocked]
   move player to Grey Abbey Library; [move the player to the chosen location and continue with the event]


What stands behind that function call is this:
Code: Select all
to say NavCheck (CheckRoom - a room): [check if a nav attempt can go through]
   if debugactive is 1:
      say "DEBUG -> NavCheck just checked your travel route out! <- DEBUG";
   if location of player is not fasttravel:
      say "You can't navigate from here.";
      now NavCheckReturn is false;
   otherwise if location of player is CheckRoom:
      say "You're already here.";
      now NavCheckReturn is false;
   otherwise:
      if debugactive is 1:
         say "DEBUG -> ...and you may travel. Pass along now. <- DEBUG";
      now NavCheckReturn is true;
User avatar
Wahn
 
Posts: 520
Joined: Mon Dec 09, 2013 2:57 pm

Return to Dev Chat

Who is online

Users browsing this forum: No registered users and 1 guest