Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Couple questions... (http://www.alice.org/community/showthread.php?t=2573)

JCHonda 04-23-2009 05:48 PM

Couple questions...
 
I am currently making an rpg game for my end semester project... and so far so good... but I have a couple of questions that would be a lot of help:

1) Say I have a method that asks a person their name, and then stores in in a variable. Is there a way of calling that variable from another method?

EX:
char1: What is your name?
input name
store name

user walks and finds char 2
when user clicks on char 2 (do char2 method)

char2: Hello there, (name!)

-----------

2) When a user creates a character and stores his/her name in the variable... is it possible to have alice change a pre-made 3D text to the users name? (A name that hovers above the users head)

TIA

James

Scott300 04-24-2009 07:58 AM

1)Ya the variables in alice are global so a variable in method: my first method can call a variable in method: my second method

2)Yes just check the properties when clicking on the 3D text there will be a field with the text, just a clue make sure you put the (as a string) function in before you put the variable in for editing the 3D text.

JCHonda 04-26-2009 02:46 PM

how do I call those variables

HisWorld 04-26-2009 02:49 PM

Just drag and drop them into a method. Just beware that changing a global varible, changes the value of it for any and all method calls to is. It maybe safer in a large game to also create local variable and have them dependent on the global variable.

JCHonda 04-26-2009 02:55 PM

whats the difference between a globlal and local variable?

HisWorld 04-26-2009 05:16 PM

It's hard for me to relate what I know with the rest of the world of programming and with alice, but I'll try.

Local variables in Alice will only effect the exact method in which they are created. Meaning you could have two different methods and in each create a variable named "player" Even though they have the same name what you do to one variable will not effect the other.

example:

method1
set "player = 1"
method2
set "player = 2"

if method1.player = 1
result true

A Global variable however is shared among all methods that use it.

example:

method1
set "global.player = 1"
method2
set "global.player = 2"

if method1.player = 1
result false

____________________________________________
I hope that helped, it hard to explain since I've just started to really get into working with Alice today. Look for my other posts I have a program or two I've made with global and local variables in them.


All times are GMT -5. The time now is 03:20 AM.

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