main

main is the routine that is called every turn after a successful verb routine (not an “xverb” like SAVE or a “You can’t go that way.” message). Let’s look at the main routine from the “New Shell” page:

routine main
{
        counter = counter + 1
        PrintStatusLine
        run location.each_turn
        runevents
        RunScripts
        if speaking not in location
                speaking = 0
}

Line by line:

  • Line 3 Increase the turn counter by 1, using the global variable counter
  • Line 4 Refresh the status line
  • Lines 5 Run the current location’s each_turn property, if any exist
  • Line 6 Run any events that are in scope
  • Line 7 Run any character scripts that exist
  • Lines 8-9 If the player is no longer in the same room as the character he or she was talking to, clear the speaking global variable

In a multi-window game with graphics, you’d want to call your “DrawGraphicWindows” routine in the main routine. And so on.