alice-teacher Scope of world booleans

Don Slater dslater at andrew.cmu.edu
Wed Nov 9 07:23:45 EST 2011


Tony has identified an issue with boolean world variables and scope. He states that setting world functions work as expected. For those who are interested, here is an example of what he is describing.

See the attached world "getClickedFunctionDemo.a2w"

I have created a world level boolean variable "clicked", with an initial value of false.
I have created a world level boolean function "getClicked" which returns the value of the "clicked" variable.
I have created a mouse-click event which sets the value of the "clicked" variable to true when the user clicks on the hare.
I have created a method for the hare called "hop". This method has the hare move up and down until the user clicks on it.

	while (not getClicked)     ==> using the world level function "getClicked"
		hare move up
		hare move down

All the best,
Don Slater

-------------- next part --------------
A non-text attachment was scrubbed...
Name: getClickedFunctionDemo.a2w
Type: application/octet-stream
Size: 726275 bytes
Desc: not available
Url : https://lists.andrew.cmu.edu/mailman/private/alice-teachers/attachments/20111109/e8a42713/attachment-0001.obj 
-------------- next part --------------


On Nov 8, 2011, at 3:24 PM, Tony Bowes wrote:

> Hi there.
> 
> From the documentation I'm lead to believe that world variables have scope over all objects brought into the world.  I'm having problems getting world boolean variables to retain their scope and be useful in IF structures on dependent objects. I can drag local boolean variables directly into the IF condition, but can't drag world booleans into there. This makes setting up game state variables more tricky than expected. Note that setting world functions that simply return the variable state work as expected, but I'd rather leave encapsulation until much later. 
> 
> Is there a simple way of tracking and checking game states?
> 
> -- 
> Tony Bowes
> ICT / IPT / Maths Teacher
> St Luke's Anglican School
> 4 Mezger St Bundaberg  Qld  4670
> 
> p: (07) 4132 7500
> f:  (07) 4132 7556
> tony-bowes at slasmail.com
> http://www.stlukes.qld.edu.au
> 
> 
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers



More information about the alice-teachers mailing list