Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: robingravel on October 02, 2002, 10:07:57 PM

Title: problem with chapter 24
Post by: robingravel on October 02, 2002, 10:07:57 PM
Hi

I tried printing with box but it doesn't work. I got
indefined symbol "var"

Here the codes:

/******************************************************************************
 SCI Template Game
 By Brian Provinciano
 ******************************************************************************
 rm001.sc
 Contains the first room of your game.
 ******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 1)
/******************************************************************************/
(use "main")
(use "controls")
(use "cycle")
(use "game")
(use "feature")
(use "obj")
(use "inv")
(use "door")
(use "jump")
(use "dpath")
/******************************************************************************/
(instance public rm001 of Rm
Title: Re:problem with chapter 24
Post by: Brian Provinciano on October 02, 2002, 10:14:32 PM
you need to declare your vars at the top of your method or procedure.

eg:

Good:
(method (foo)
   (var a)
   Print("Hello")
   Print("There")
)

Bad:
(method (foo)
   Print("Hello")  
   (var a)
   Print("There")
)
Title: Re:problem with chapter 24
Post by: robingravel on October 02, 2002, 10:26:04 PM
Thanks Brian.

Now I got "out bracket" message.

Here my codes:

(instance RoomScript of Script
 (properties)
 (method (handleEvent pEvent)
  (super:handleEvent(pEvent))

  /*****************************************
   * Handle the possible said phrases here *
   *****************************************/
  (if(Said('look'))
   (method (foo)
    (var button)
    //= button
     Print("You are in an empty room")
     Print(
     "Do you want to click Yes or No?"
     #title "Click What?"
     #font LARGE_FONT
     #icon 0 0 0
     #button " Yes " 1
     #button " No " 0
    )
    (if(== button 1)
     Print("You clicked YES")
     )(else
     Print("You clicked NO")
      )
     )
    )
   )
  )
 )
)
Title: Re:problem with chapter 24
Post by: Brian Provinciano on October 02, 2002, 11:53:07 PM
the "  (method (foo)" was just an example of using vars. It's not to be in your code.
Title: Re:problem with chapter 24
Post by: Brian Provinciano on October 02, 2002, 11:55:56 PM
Do it like this:

(method (handleEvent pEvent)    
  // right after your method declaration
  (var button)

  (super:handleEvent(pEvent))

  /*****************************************
  * Handle the possible said phrases here *
  *****************************************/
  (if(Said('look'))

    //= button

    Print("You are in an empty room")
    Print(
    "Do you want to click Yes or No?"
    #title "Click What?"
    #font LARGE_FONT
    #icon 0 0 0
    #button " Yes " 1
    #button " No " 0
    )
    (if(== button 1)
    Print("You clicked YES")
    )(else
    Print("You clicked NO")
      )
    )
    )
)
Title: Re:problem with chapter 24
Post by: robingravel on October 03, 2002, 08:31:12 AM
Thanks Brian.

I didn't get an error from compiler this time.

Either I click on yes and no buttons, i got "you clicked yes".

Here the code:

(instance RoomScript of Script
 (properties)
(method (handleEvent pEvent)
  // right after your method declaration
  (var button)

  (super:handleEvent(pEvent))

  /*****************************************
  * Handle the possible said phrases here *
  *****************************************/
  (if(Said('look'))

    == button

    Print("You are in an empty room")
    Print(
    "Do you want to click Yes or No?"
    #title "Click What?"
    #font LARGE_FONT
    #icon 0 0 0
    #button " Yes " 1
    #button " No " 0
    )
    (if(== button 1)
     Print("You clicked YES")
    )(else
     Print("You clicked NO")
      )
    )
    )
)

Robin Gravel
Title: Re:problem with chapter 24
Post by: Steven Melenchuk on October 03, 2002, 05:38:19 PM
Now here, you just want to assign 'button' to the last Print value, e.g.:

= button    Print(
    "Do you want to click Yes or No?"
    #title "Click What?"
.
.
.

Title: Re:problem with chapter 24
Post by: robingravel on October 03, 2002, 06:07:14 PM
Thanks Steven. It works.

Robin Gravel