Peer Review of "Through the Looking Glass"

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Peer Review of "Through the Looking Glass"

Post by Sandsquish »

Hello,

I've finished the port of Gareth Rees "Through the Looking Glass" tutorial game and would appreciate it if you would take a look at the code and post any suggestions you might have to improve the code.

There are a couple of odd problems that I can't track down here. The script for the white kitten stops running after anything in the game is picked up by the player and the game will only display monospaced type in the Carbon version of Hugo v3.1.02, but it uses proportional type in the GLK Mac version.

I plan to alter the tutorial to make it applicable to Hugo and then ask Gareth Rees for permission to upload it to the IF Archive shortly, but I'd rather wait until I've heard from other Hugo programmers before I start on that. This is my first Hugo project, so I'm sure there are some things I could have handled better here.

Code: Select all

! #set DEBUG
#ifset DEBUG
#switches -d
#endif

verb "untangle", "roll", "wind"
   * "up" held    DoUntangle
   *  held "up"   DoUntangle
   *  held        DoUntangle

verb "look", "l", "examine", "x", "watch"
   * "at" object "in" (mirror)   DoReflect
   *  object "in" (mirror)       DoReflect

#set USE_PLURAL_OBJECTS
#set VERBSTUBS
#include "verblib.g"
#include "hugolib.h"
#include "resource.h"

routine DoUntangle
   {
  "What curious ideas you have!"
   }

routine DoReflect
   {
   if (object = mirror, hearth) or 
      (player not in mantelpiece and player not in armchair)
      "You can't see that in the looking glass."
   else
      {
     "The looking-glass ";
      print object.name;
      if player in mantelpiece
       " looks very misty and blurred."
      else
         {
       " looks just like the real ";
         print object.name;
       " only all reversed, left for right."
         }
      } 
   }

attribute male

replace AssignPronoun(obj)
   {
#ifclear OLD_STYLE_PRONOUNS
   if obj >= it_object and obj <= them_object
      return
#endif
   if parser_data&#91;PARSER_STATUS&#93; & PRONOUNS_SET
      return
   if obj = player
      return
   if not obj.#noun and not obj.#adjective
      return
   if obj is plural
      them_obj = obj
   elseif obj is female
      her_obj = obj
   elseif obj is male
      him_obj = obj
   else
      it_obj = obj
   &#125;

routine init
   &#123;
   counter = -1

   STATUSTYPE = 0                   
   TEXTCOLOR = BLACK
   BGCOLOR = BRIGHT_WHITE
   SL_TEXTCOLOR = BRIGHT_WHITE
   SL_BGCOLOR = BLACK
   
   prompt = ">"
   color TEXTCOLOR, BGCOLOR

   cls
   
  "It's a cold winter day outside, but in the looking-glass house 
   it's summer. All you need to do is pretend there's a way of getting 
   through into it somehow ...\n"
   
   pause
   LoadPicture&#40;"alice", "alice1"&#41;
   
   Font&#40;BOLD_ON | DEFAULT_FONT&#41;
  "Through the Looking Glass"
   Font&#40;BOLD_OFF&#41;
  "An Interactive Tutorial"
   print BANNER

   player = you
   location = drawing_room 
   old_location = location
   
   move player to location
   FindLight&#40;location&#41;
   DescribePlace&#40;location&#41;
   location is visited
   CalculateHolding&#40;player&#41;
   setscript&#91;Script&#40;white_kitten, 2&#41;&#93; = &PlayfulKittens, nothing,
      &LoopScript, nothing
   setscript&#91;Script&#40;black_kitten, 2&#41;&#93; = &PlayfulKittens, nothing,
      &LoopScript, nothing

#ifset USE_PLURAL_OBJECTS
   InitPluralObjects
#endif
   &#125;

routine main
   &#123;
   counter = counter + 1
   PrintStatusLine
   run location.each_turn
   runevents
   RunScripts
   if parent&#40;speaking&#41;~=location
      speaking = 0
   &#125;

player_character you "you"
   &#123;
   size 55
   &#125;

room drawing_room "Drawing Room"
   &#123;
   long_desc
     "The gentle sound of snow against the window pane suggests that 
      it's cold outside, and you're glad to be here in the warmth. 
      The drawing room is reflected in the large looking glass on the 
      wall above the mantelpiece, and a very comfortable room it is 
      too, with a warm hearth, a soft rug, and an armchair that you 
      can curl up and sleep in."
   before
      &#123;
      location DoGo
         &#123;
         if object = d_obj, out_obj
            &#123;
            if player in mantelpiece
               &#123;
              "You drop down into the warm and comfortable armchair."
               move player to armchair
               &#125;
            elseif player in armchair
               &#123;
              "You hop down from the armchair."
               move player to drawing_room
               &#125;
            else
               return false
            &#125;
         elseif object = u_obj
            &#123;
            if player in armchair and armchair is near_mantel
               &#123;
              "You clamber up onto the mantelpiece."
               move player to mantelpiece
               &#125;
            else 
               return false
            &#125;
         else
            return false
         &#125;
      &#125;
   &#125;

scenery window_pane "window"
   &#123;
   nouns "window", "pane", "snow"
   adjectives "window"
   article "the"
   long_desc
     "Outside the window it's snowing gently, and you're glad to be 
      in here in the warmth."
   before
      &#123;
      object DoOpen
         &#123;
        "You wouldn't want to catch a chill, would you? Better leave 
         the window shut."
         &#125;
      &#125;
   is openable
   in drawing_room
   &#125;

object red_queen "red queen"
   &#123;
   nouns "queen", "piece"
   adjectives "red", "black", "chess"
   article "the"
   long_desc
     "She's a fierce little chess piece."
   after
      &#123;
      object DoGet
         &#123;
         if white_kitten.currently = PLAYING_WITH_QUEEN
            &#123;
            white_kitten.currently = PLAYING_WITH_CHAIR
            red_queen is not hidden
            return false
            &#125;
         elseif black_kitten.currently = PLAYING_WITH_QUEEN
            &#123;
            black_kitten.currently = PLAYING_WITH_CHAIR
            red_queen is not hidden
            return false
            &#125;
         else
            return false
         &#125;
      object DoPutIn
         &#123;
         if xobject = chess_board
           "Alone on the chess board, the red queen is monarch of all      
            she surveys."
         else
            return false
         &#125;
      &#125;
   size 1
   is female
   &#125;
   
plural_class missing_pieces
   &#123;
   nouns "pawns", "rooks", "castles", "knights", "horses", \
     "bishops", "queens", "kings", "pieces"
   adjectives "missing", "red", "white", "black", "chess"
   article "the"
   plural_of pawn, rook, knight, bishop, queen, king
   before
      &#123;
      object
         &#123;
        "Alas, the chess pieces seem to be missing. Those naughty 
         kittens!"
         &#125;
      &#125;
   &#125;
   
class missing_piece
   &#123;
   noun "piece"
   adjectives "missing", "white", "chess"
   article "the"
   plural_is missing_pieces
   before
      &#123;
      object
         &#123;
        "Alas, that chess piece seems to be missing. Those naughty 
         kittens!"
         &#125;
      &#125;
   is hidden, static
   &#125;

missing_piece pawn "pawn"
   &#123;
   noun "pawn"
   adjectives "red", "black"
   in drawing_room
   &#125;

missing_piece rook "rook"
   &#123;
   nouns "rook", "castle"
   adjectives "red", "black"
   in drawing_room
   &#125;
   
missing_piece knight "knight"
   &#123;
   nouns "knight", "horse"
   adjectives "red", "black"
   in drawing_room
   &#125;
   
missing_piece bishop "bishop"
   &#123;
   noun "bishop"
   adjectives "red", "black"
   in drawing_room
   &#125;
   
missing_piece queen "queen"
   &#123;
   noun "queen"
   in drawing_room
   &#125;
   
missing_piece king "king"
   &#123;
   noun "king"
   adjectives "red", "black"
   in drawing_room
   &#125;

object chess_board "chess board"
   &#123;
   nouns "board", "board"
   adjectives "chess", "checker", "chequer"
   article "the"
   initial_desc
     "An abandoned chess board lies on the floor."
   long_desc
     "It's left here from the game you were playing just now, but the 
      pieces are all missing--the kittens will insist on playing 
      with them."
   size 3
   capacity 5
   holding 0
   is platform
   in drawing_room
   &#125;

scenery hearth "hearth"
   &#123;
   nouns "hearth", "fireplace", "place"
   adjective "fire"
   article "the"
   long_desc
     "Looking at the hearth, you wonder if they have a hearth in the 
      looking-glass house. You can never tell by looking, unless your 
      fire smokes, and then smoke comes up in the looking-glass room 
      too--but that may be only pretense, just to make it look as if 
      they had a fire."
   in drawing_room
   &#125;

attribute hiding_queen

object rug "rug"
   &#123;
   nouns "rug", "hearthrug", "carpet"
   adjectives "hearth", "indian", "arabian", "soft", "beautiful"
   article "the"
   long_desc
     "It's a beautiful rug, made in some far off country, perhaps 
      India or Araby, wherever those might be."
   before
      &#123;
      object DoLookUnder
         &#123;
         if player in self
           "You try to lift up a corner of the rug, but fail. After
            a while, you realize that this is because you are standing 
            on it. How curious the world is!"
         elseif player in mantelpiece or player in armchair 
           "You're unable to reach the rug from here." 
         elseif self is hiding_queen
            &#123;
           "You lift up a corner of the rug and, peering underneath, 
            discover the red queen from the chess set."
            move red_queen to player
            self is not hiding_queen
            &#125;
         else
            return false
         &#125;  
      object DoGet
         &#123;
        "The rug is much too large and heavy for you to carry."
         &#125;
      object DoMove, DoPull, DoPush
         &#123;
        "But a hearth rug is meant to be next to the hearth!"
         &#125;
      &#125;
      capacity 987
      holding 0
      is hidden, static, platform, enterable, hiding_queen
      in drawing_room
   &#125;
   
attribute near_mantel

object armchair "armchair"
   &#123;
   nouns "chair", "armchair"
   adjective "arm", "huge"
   article "the"
   long_desc
      &#123;
     "It's a huge armchair, the perfect place for a kitten or a 
      little girl to curl up in and doze. It has been pushed over 
      to the ";
         &#123;
         if self is near_mantel
           "fireplace."
         else
           "window."
         &#125;
      &#125;
   before
      &#123;
      object DoMove, DoPush, DoPull
         &#123;
         if white_kitten.currently = PLAYING_WITH_ALICE or
            black_kitten.currently = PLAYING_WITH_ALICE
           "Not with a kitten in your arms!"
         elseif white_kitten.currently = PLAYING_WITH_CHAIR or
            black_kitten.currently = PLAYING_WITH_CHAIR
            &#123;
            local this_kitten
            if white_kitten.currently = PLAYING_WITH_CHAIR
               this_kitten = white_kitten
            else
               this_kitten = black_kitten
           "You are about to start moving the chair when you 
            notice that ";
            print The&#40;this_kitten&#41;;
          " is right in the way. It's a good thing you spotted it, or 
            you would have squashed flat the poor little thing."
            &#125;
         elseif player not in drawing_room 
            &#123;
           "You'll have to get off ";
            print The&#40;parent&#40;player&#41;&#41;;
          " first."
            &#125;
         elseif self is near_mantel
            &#123;
           "You push the armchair away from the hearth."
            self is not near_mantel
            &#125;
         else
            &#123;
           "You push the armchair over to the hearth."
            self is near_mantel
            &#125;
         &#125;
      object DoClimb, DoEnter
         &#123;
        "You jump into the warm and comfortable armchair."
         move player to armchair
         &#125; 
      &#125;
      capacity 233
      holding 0
      reach mantelpiece
      is hidden, static, platform, enterable, not near_mantel
      in drawing_room
   &#125;
   
object mantelpiece "mantelpiece"
   &#123;
   nouns "mantelpiece", "mantel"
   article "the"
   long_desc
     "It's higher off the ground than your head, but it looks wide 
      enough and sturdy enough to support you."
   before
      &#123;
      object DoEnter, DoClimb
         &#123;
         if player not in armchair and armchair is not near_mantel
           "You can't reach the mantelpiece from here."
         elseif WhatsIn&#40;player&#41; > 0
           "Your hands are too full."
         else
            &#123;
           "You scramble up onto the mantelpiece."
            move player to mantelpiece
            &#125;
         &#125;
      object DoExit 
         &#123;
        "You jump into the warm and comfortable armchair."
         move player to armchair
         &#125; 
      xobject DoPutIn, DoTakeOff 
         &#123;
         if player not in self and 
           &#40;player not in armchair or armchair is not near_mantel&#41;
           "The mantelpiece is so high that you can't reach."
         else
            return false
         &#125;
      &#125;
      capacity 144
      holding 0
      reach armchair, mirror
      is hidden, static, platform, enterable
      in drawing_room
   &#125;

object mirror "looking glass"
   &#123;
   nouns "mirror", "glass"
   adjectives "looking"
   article "the"
   long_desc
      &#123;
      if player in mantelpiece
        "Strangely, the glass is beginning to melt away, just like 
         a bright silvery mist."
      elseif player in armchair
        "In the looking glass you can see the drawing room of the 
         looking-glass house. What you can see is very much the same 
         as this drawing room, only all reversed, left for right. 
         But you are sure that out of the corners of the glass, where 
         you can't see, the looking-glass world is quite different 
         from yours."
      else
        "In the looking glass you can see the ceiling of the drawing 
         room of the looking-glass house. It looks much the same as 
         the ceiling of your drawing room."
      &#125;
   before
      &#123;
      object
         &#123;
         if player not in mantelpiece
            &#123;
            if verbroutine = &DoLook
               return false
            else
              "You can't reach the looking glass from where you're 
               standing."
            &#125;
         elseif verbroutine = &DoTouch, &DoMove, &DoPush, &DoPull
           "Your hand goes right through the silvery mist!"
         elseif verbroutine = &DoEnter
            &#123;
           "Your hand goes right through the silvery mist, and in 
            another moment the rest of you follows, and you are through 
            the glass ..."
            LoadPicture&#40;"alice", "alice3"&#41;
            endflag = true
            &#125;
         else
            return false
         &#125;
      xobject DoThrowAt
         &#123;
        "You don't want seven years of bad luck, do you?"
         &#125;
      &#125;
   is hidden, static
   in drawing_room
   &#125;

attribute tangled

object worsted "ball of worsted" 
   &#123;
   nouns "ball", "wool", "worsted"
   adjectives "blue", "fine", "ball"
   article "a"
   initial_desc
     "A discarded ball of worsted lies on the floor here."  
   long_desc
      &#123;
      if self is tangled
        "It's in a terrible tangle. All that time you spent rolling 
         it up, and now look at it!"
      else
        "It's a ball of fine blue wool, all rolled up in preparation 
         for some embroidery."
      &#125;
   before
      &#123;
      object DoUntangle
         &#123;
         if self is tangled
            &#123;
           "You're as quick as can be at rolling up balls of wool, 
            though you say so yourself! Soon it's neat and tidy again."
            self is not tangled
            &#125;
         else
           "But someone already has! The ball of wool is neat and tidy."
         &#125;
      &#125;
   after
      &#123;
      object DoGet
         &#123;
         if white_kitten.currently = PLAYING_WITH_BALL
            &#123;
            worsted is not hidden
            white_kitten.currently = PLAYING_WITH_CHAIR
            return false
            &#125;
         elseif black_kitten.currently = PLAYING_WITH_BALL
            &#123;
            worsted is not hidden
            black_kitten.currently = PLAYING_WITH_CHAIR
            return false
            &#125;
         else
            return false
         &#125;
      &#125;
   size 1
   is not tangled
   in drawing_room
   &#125;

attribute playing
property  other_kitten
property  currently
enumerate
   &#123;
   PLAYING_WITH_CHAIR, PLAYING_WITH_ALICE, PLAYING_WITH_QUEEN, 
      PLAYING_WITH_BALL
   &#125;

class kitten
   &#123;
   nouns "kitten", "kitty", "cat"
   article "a"
   short_desc
      &#123;
      if self.currently = PLAYING_WITH_QUEEN
         &#123;
         print CArt&#40;self&#41;;
       " is playing with the red queen."
         &#125;
      elseif self.currently = PLAYING_WITH_BALL
         &#123;
         print CArt&#40;self&#41;;
       " is playing with a ball of worsted."
         &#125;
      elseif self.currently = PLAYING_WITH_CHAIR
         &#123;
         if self.other_kitten.currently = PLAYING_WITH_CHAIR
            &#123;
           "Two kittens, one white and one black, are playing together 
            by the armchair."
            self.other_kitten is already_listed
            &#125;
         else
            &#123;
            print CArt&#40;self&#41;;
          " is playing by the armchair."
            &#125;
         &#125;
      else
         return false
      &#125;
   long_desc
      &#123;
     "What a beautiful kitten "; 
      print The&#40;self&#41;; 
    " is. Why, it's quite definitely your favorite of the pair, and 
      much prettier than that naughty "; 
      print self.other_kitten.name; "."
      &#125;
   ignore_response
      &#123;
      print CThe&#40;self&#41;;
    " twitches its whiskers and looks at you with such a clever 
      expression that you are certain it understands every word you 
      are saying."
      &#125;
   before
      &#123;
      object DoGet
         &#123;
         if self.other_kitten in player
           "You can't hold two kittens at once!"
         else
            &#123;
            self.currently = PLAYING_WITH_ALICE
            move self to player
           "You pick up ";
            print The&#40;self&#41;;
         ". What a beautiful creature it is!"
            &#125;
         &#125;
      xobject DoThrowAt
         &#123;
         if object ~= red_queen, worsted
            &#123;
            move object to drawing_room
           "You toss ";
            print The&#40;object&#41;;
          " onto the floor. "
            Perform&#40;&DoGive, object, self&#41;
            &#125;
         else
            Perform&#40;&DoGive, object, self&#41;
         &#125;
      &#125;
   after
      &#123;
      object DoDrop, DoPutOnGround
         &#123;
         self.currently = PLAYING_WITH_CHAIR
         move self to drawing_room
         print CThe&#40;self&#41;;
       " squirms out of your arms and scampers away."
         &#125;
      object DoPutIn
         &#123;
         self.currently = PLAYING_WITH_CHAIR
         print CThe&#40;self&#41;;
       " jumps off ";
         print The&#40;parent&#40;self&#41;&#41;;
      ", landing lightly on the floor before scampering away."
         move self to drawing_room
         &#125;
      object DoKiss
         &#123;
        "You give "; 
         print The&#40;self&#41;; 
       " a little kiss on its nose, and it looks sweetly and demurely 
         at you."
         &#125;
      object DoHit
         &#123;
        "You would never do such a beastly thing to such a defenseless 
         little animal!"
         &#125;
      xobject DoShow
         &#123;
         print CThe&#40;self&#41;;
       " bats a paw at "; 
         print The&#40;object&#41;; "."
         &#125;
      xobject DoGive
         &#123;
         if object ~= red_queen, worsted
            &#123;
            print CThe&#40;self&#41;;
          " just examines "; 
            print The&#40;object&#41;;
          " with a quizzical expression."
            &#125;
         else
            &#123;
            move object to drawing_room
           "You toss ";
            print The&#40;object&#41;;
          " onto the floor and ";
            print The&#40;self&#41;;
            if self in player
               &#123;
               move self to drawing_room
             " squirms out of your grasp and";
               &#125;
          " scampers after it";
            if object = worsted
               &#123;
               self.currently = PLAYING_WITH_BALL
               worsted is hidden
               worsted is tangled
            ", quickly turning the neat ball into a tangle";
               &#125;
            else 
               self.currently = PLAYING_WITH_QUEEN
               red_queen is hidden
           "."
            if object = worsted
               LoadPicture&#40;"alice", "alice2"&#41;
           &#125;
         &#125;
      &#125;
   currently PLAYING_WITH_CHAIR
   size 5
   is living
   &#125;

plural_class kittens
   &#123;
   nouns "kittens", "kitties", "cats"
   single_noun "kitten"
   plural_of white_kitten, black_kitten
   &#125;

kitten white_kitten "white kitten"
   &#123;
   adjective "white"
   plural_is kittens
   other_kitten black_kitten
   is playing
   in drawing_room
   &#125;

kitten black_kitten "black kitten"
   &#123;
   adjective "black"
   plural_is kittens
   other_kitten white_kitten
   is not playing
   in drawing_room
   &#125;

routine PlayfulKittens
   &#123;
   local this_kitten, activity
   activity = random&#40;5&#41;
   if this_kitten is playing
      &#123;
      this_kitten is not playing
      if random&#40;3&#41; = 3
         return false
      else
         &#123;
         indent
         print CThe&#40;this_kitten&#41;;
         select this_kitten.currently
            case PLAYING_WITH_ALICE
               &#123;
               select activity
                  case 1
                   " mews plaintively."
                  case 2
                   " purrs quietly to itself."
                  case 3
                   " purrs contentedly to itself."
                  case 4
                   " rubs its ears against you."
                  case 5
                     &#123;
                     move this_kitten to drawing_room
                     this_kitten.currently = PLAYING_WITH_CHAIR
                   " squirms out of your arms and scampers away."
                     &#125;
               &#125;
            case PLAYING_WITH_QUEEN
               &#123;
               select activity
                  case 1
                   " bats at the red queen with its paw."
                  case 2
                   " stops playing and sits up, pretending to be  
                     innocent of any kittenish tendencies."
                  case 3
                   " knocks the red queen across the floor and chases 
                     after it."
                  case 4
                   " stops to wash itself."
                  case 5
                   " bites the red queen and shakes it to make sure that 
                     it's dead."
               &#125;
            case PLAYING_WITH_BALL
               &#123;
               select activity
                  case 1
                   " bats at the ball of worsted with its paw."
                  case 2
                   " pushes the ball of worsted across the floor and  
                     chases after it."
                  case 3
                   " leaps onto the ball of worsted and grapples bravely 
                     with it."
                  case 4
                   " jumps into the ball of worsted and gets tangled up
                     in a mess of threads."
                  case 5
                   " stops playing and scratches its ears."
               &#125;
            case PLAYING_WITH_CHAIR
               &#123;
               if this_kitten.other_kitten.currently = \
                  PLAYING_WITH_CHAIR and random&#40;2&#41; = 2
                  &#123;
                  select activity
                     case 1
                      " chases after ";
                     case 2
                      " jumps on top of ";
                     case 3
                      " washes ";
                     case 4
                      " scampers around the armchair and ";
                     case 5
                      " bats at ";
                  print The&#40;this_kitten.other_kitten&#41;;
                  select activity
                     case 1, 3
                      "."
                     case 2
                      " and they roll around on the floor."
                     case 4
                      " chases after it."
                     case 5
                      " with its paw."
                  &#125;
               else
                  select activity
                     case 1
                      " scampers after a speck of dust."                
                     case 2
                      " rolls around on the floor."                  
                     case 3
                      " sits up and washes its tail."                
                     case 4
                      " scratches its head on the armchair."                  
                     case 5
                      " chases its tail."
               &#125; 
         &#125; 
      &#125;
   else
      &#123;
      this_kitten is playing     
      return false
      &#125; 
   &#125;
   
resource "alice"
   &#123;
  "alice1.jpg"
  "alice2.jpg"
  "alice3.jpg"
   &#125;

Vitriola

Post by Vitriola »

Does it ask me for my bank account information somewhere in there?

User avatar
Ice Cream Jonsey
Posts: 30193
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

Hey, this is really cool. Good work, man.

I am swamped with work, but I'll see if I can track down the problems that you specifically noted and see if I can see what's causing them.

Good job!
the dark and gritty...Ice Cream Jonsey!

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Post by Sandsquish »

Vitriola wrote:Does it ask me for my bank account information somewhere in there?
No, that would be the Hugo port of Douglas Adams' "Bureaucracy." :-)

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Peer Review of "Through the Looking Glass"

Post by Sandsquish »

Ice Cream Jonsey wrote:Good work, man.
Thanks.
Ice Cream Jonsey wrote:I'll see if I can track down the problems that you specifically noted
That'd be great. They're both pretty baffling bugs.

Kent
Posts: 119
Joined: Fri Jun 27, 2003 12:10 pm

Post by Kent »

For the font problem, try adding

Code: Select all

DEFAULT_FONT = PROP_ON
before

Code: Select all

Font&#40;BOLD_ON | DEFAULT_FONT&#41;
in the init routine.

As for the kittens, I'll have to look at this some more when I get a chance. I'm puzzled by the PlayfulKittens routine, since

Code: Select all

   local this_kitten, activity
   activity = random&#40;5&#41;
   if this_kitten is playing
means that the uninitialized this_kitten local is always 0 when the routine runs. And 0 (i.e., the nothing object) should never have the 'playing' attribute.

Ah, wait. I see. Later in the routine you do set 'this_kitten is playing', which if this_kitten is 0 translates to 'nothing is playing'.

You're going to have to make sure your script sets up this_kitten as an argument to PlayfulKittens instead of just a local, is all.

At least I think that should fix it.

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Post by Sandsquish »

Kent wrote:For the font problem, try adding DEFAULT_FONT = PROP_ON before Font(BOLD_ON | DEFAULT_FONT) in the init routine.
Thanks. (Font(DEFAULT_FONT) needed to be added before the introductory text too.)
Kent wrote:the uninitialized this_kitten local is always 0 when the routine runs. [...] You're going to have to make sure your script sets up this_kitten as an argument to PlayfulKittens instead of just a local, is all. At least I think that should fix it.
"The Vault of Hugo" also appears to have a routine with a couple of uninitialized local variables that seem to take the values of the parameters passed to the routine. (CharShakeHead). But, maybe I misunderstood it.

I tried changing the first few lines of the routine to

Code: Select all

routine PlayfulKittens&#40;this_kitten&#41;
   &#123;
   local activity
   activity = random&#40;5&#41;
But that doesn't seem to change anything. Here's what the script monitor is saying ...

>z
Time passes...
[Script for obj. 52 (white kitten), step 1: $F12, obj. 0 (nothing)]
[Script for obj. 53 (black kitten), step 1: $F12, obj. 0 (nothing)]
The black kitten scampers after a speck of dust.
[Script for obj. 52 (white kitten), step 2: $6AF, obj. 0 (nothing)]
[Looping script for obj. 52 (white kitten)]
[Script for obj. 53 (black kitten), step 2: $6AF, obj. 0 (nothing)]
[Looping script for obj. 53 (black kitten)]
[Script for obj. 52 (white kitten), step 1: $F12, obj. 0 (nothing)]
The white kitten jumps on top of the black kitten and they roll around on the
floor.
[Script for obj. 53 (black kitten), step 1: $F12, obj. 0 (nothing)]

>Take the ball of wool.
Taken.
[Script for obj. 53 (black kitten), step 2: $6AF, obj. 0 (nothing)]
[Looping script for obj. 53 (black kitten)]

>z
Time passes...
[Script for obj. 53 (black kitten), step 1: $F12, obj. 0 (nothing)]
The black kitten bats at the white kitten with its paw.
[Script for obj. 53 (black kitten), step 2: $6AF, obj. 0 (nothing)]
[Looping script for obj. 53 (black kitten)]
[Script for obj. 53 (black kitten), step 1: $F12, obj. 0 (nothing)]

bruce
Posts: 2544
Joined: Tue Jun 04, 2002 10:43 pm

Post by bruce »

Speaking of kittens,

http://www.burstfilms.com/kitten.html

Bruce

EDIT: Except it's down at the moment. Crap.

Guest

Post by Guest »

Sandsquish wrote:"The Vault of Hugo" also appears to have a routine with a couple of uninitialized local variables that seem to take the values of the parameters passed to the routine. (CharShakeHead). But, maybe I misunderstood it.
Whoops. That's actually a leftover, probably, from when Hugo's routine definitions looked more Inform-like. Truth is, arguments are just the first local variables in a routine, so

Code: Select all

routine MyRoutine&#40;first_arg&#41;
&#123;
     ...
is the same as

Code: Select all

routine MyRoutine
&#123;
     local first_arg
     ...
since either can be called as MyRoutine(value) and have first_arg = value.

Now, for your purposes, note that the first two arguments of the character script routine examples in sample.hug are

Code: Select all

local char, obj
In other words, the character the routine is being called for, and the object (if any) to be acted on. Try making your first initialization

Code: Select all

local this_kitten, obj
or change the routine to

Code: Select all

routine PlayfulKittens&#40;this_kitten, obj&#41;
(I haven't tested this yet; I'll try to get the time to do it if it doesn't work for you.)
[/code]

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Post by Sandsquish »

Anonymous wrote:note that the first two arguments [...] are [...] the character the routine is being called for, and the object (if any) to be acted on. [...] change the routine to routine PlayfulKittens(this_kitten, obj)
The routine only makes use of the first argument but I tried adding the second one, just in case something odd was going on. The results were the same, though. The second kitten's script stops whenever something is picked up by the player character.

Guest

Post by Guest »

Ah, dammit. Mea culpa. Sorry for not getting on the trail of this sooner. As Hugo has become more and more stable I'm less and less likely in the last few years to suspect a problem in the library, etc. But it turns out that something I "fixed" as recently (I think) as Future Boy!'s post-release was screwing up character scripting.

Try: http://www.generalcoffee.com/hugo/beta/hugolib.zip

I found this by investigating what was going on with the 'setscript' array and found that some bad code was setting something it wasn't supposed to. Yay debugger, I guess. Once I actually traced through what was going on (after my eyeball debugging of your code didn't work), it was pretty quick to figure out.

Again, sorry for not nailing this one sooner. Let me know if this solves it for you.

Sandsquish
Posts: 12
Joined: Wed Apr 13, 2005 11:41 am

Post by Sandsquish »

Anonymous wrote:Let me know if this solves it for you.
That works. Thanks.
Anonymous wrote:Yay debugger, I guess.
The hdhelp.hlp file is missing from the Mac (Darwin) version at the archive. I grabbed a copy of it from the Linux version, but I'm still not sure how to use the debugger.

Guest

Post by Guest »

Whoops. I'll fix that package to include the help file.

The debugger is a pretty handy tool, I find, for figuring out what's going wrong in a program. Any debugger, that is. The Hugo Debugger has a fairly comprehensive set of standard debugger functions for stepping line-by-line through a program, setting breakpoints on lines or values, watching variables or objects, etc. It's probably worth experimenting with. If you need some help, ask away.

Kent
Posts: 119
Joined: Fri Jun 27, 2003 12:10 pm

Post by Kent »

I swear, everytime I hit Submit I realize goddammit I didn't log in again.

And now I realize goddammit I didn't check the log me in every time checkbox when I logged in this time.

Post Reply