Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Couple questions...
Old
JCHonda
Guest
 
Status:
Posts: n/a
Default Couple questions... - 04-23-2009, 05:48 PM

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
   
Reply With Quote
Old
Scott300
Senior Member
 
Status: Offline
Posts: 80
Join Date: Feb 2009
Location: Ohio
Default 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.
  Send a message via AIM to Scott300 Send a message via MSN to Scott300  
Reply With Quote
Old
JCHonda
Guest
 
Status:
Posts: n/a
Default 04-26-2009, 02:46 PM

how do I call those variables
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 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.
   
Reply With Quote
Old
JCHonda
Guest
 
Status:
Posts: n/a
Default 04-26-2009, 02:55 PM

whats the difference between a globlal and local variable?
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 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.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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