problem with chapter 24

Robin_Gravel 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
Brian_Provinciano 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")
)
Robin_Gravel 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")
)
)
)
)
)
)
)
Brian_Provinciano the " (method (foo)" was just an example of using vars. It's not to be in your code.
Brian_Provinciano Do it like this:

(method (handleEvent pEvent)
// right after your method declaration
[color=Yellow](var button)[/color]

(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 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
Steven Melenchuk 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?"
.
.
.

Robin_Gravel Thanks Steven. It works.

Robin Gravel