Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Change object's (parameter) variable in a World Method. (http://www.alice.org/community/showthread.php?t=4288)

SonicSam 04-23-2010 08:12 AM

Change object's (parameter) variable in a World Method.
 
I have 40 squares (tile) each with a "HidingObject" object variable I added in via the Properties Tab.

[IMG]http://sonicsam.net/files/dump/square_14567.png[/IMG]

What I am trying to do via a World Method is assign other objects to it.

[B]HOWEVER[/B]

[IMG]http://sonicsam.net/files/dump/1_32218.png[/IMG]

What I am trying to do is set

[B]Tile[/B].HiddenObject set value to [B]Object[/B]
Bolded items are parameters.

However, it will not let me specify a parameter, to access its variable.

The only solution I see is to do an IF statement for every square I have. (40 if statements)

[IMG]http://sonicsam.net/files/dump/forced_63421.png[/IMG]

So in conclusion

I am trying to change a variable of a object, specified via a parameter of a world method.

Help would be appreciated :)

x2495iiii 04-23-2010 01:44 PM

Put simply: you can't. You need to fake it by using one of the built in variables that all of the objects have. For example, since you need an object variable, you could have Tile set it's vehicle to Object, then reference it accordingly (since Alice will let you reference and alter the value of the Vehicle of a parameter).

SonicSam 04-23-2010 03:24 PM

[QUOTE=x2495iiii;20237]Put simply: you can't. You need to fake it by using one of the built in variables that all of the objects have. For example, since you need an object variable, you could have Tile set it's vehicle to Object, then reference it accordingly (since Alice will let you reference and alter the value of the Vehicle of a parameter).[/QUOTE]

Hello,

Setting the Tile's vehicle to the object won't work due to limitations in what I'm trying to do (I would explain, but for the sake of simplicity I'll just say I know that won't work).

What I ended up doing was 40 if's in a Do Together,

if Tile = square { square.HidingObject set to Object }
if Tile = square2 { square2.HidingObject set to Object }
if Tile = square3 { square3.HidingObject set to Object }

It works great and while it is a little work around, I'm satisfied :)

Thanks,
Sam

x2495iiii 04-23-2010 06:49 PM

Glad you got it working and sorry the simple, obvious solution didn't work. Believe me, I'd love more references to references in Alice as well.


All times are GMT -5. The time now is 03:49 PM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.