Author Topic: problem with chapter 24  (Read 2221 times)

0 Members and 1 Guest are viewing this topic.

Offline robingravel

problem with chapter 24
« 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
« Last Edit: October 02, 2002, 10:09:28 PM by Robin_Gravel »



Offline Brian Provinciano

Re:problem with chapter 24
« Reply #1 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")
)

Offline robingravel

Re:problem with chapter 24
« Reply #2 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")
      )
     )
    )
   )
  )
 )
)

Offline Brian Provinciano

Re:problem with chapter 24
« Reply #3 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.

Offline Brian Provinciano

Re:problem with chapter 24
« Reply #4 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")
      )
    )
    )
)

Offline robingravel

Re:problem with chapter 24
« Reply #5 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

Offline Steven Melenchuk

Re:problem with chapter 24
« Reply #6 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?"
.
.
.

----------------
Steven Melenchuk
"Hopefully, next time you won't play around with gauges you don't understand!"

Offline robingravel

Re:problem with chapter 24
« Reply #7 on: October 03, 2002, 06:07:14 PM »
Thanks Steven. It works.

Robin Gravel


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.036 seconds with 17 queries.