Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
Problems with variables in Alice 2.2
Old
CaptainLizard
Junior Member
 
Status: Offline
Posts: 11
Join Date: Aug 2012
Default Problems with variables in Alice 2.2 - 10-17-2012, 10:07 AM

So i have a simple assignment in class to make a combination for a lock and make it open when you input the combination correctly. But the problem I seem to be having is that my variables will not change at all. It's as if the variables don't get called at all. Any help would be appreciated! Attached is what I have of the program.
Attached Files
File Type: a2w lock.a2w (208.4 KB, 5 views)
   
Reply With Quote
Old
CaptainLizard
Junior Member
 
Status: Offline
Posts: 11
Join Date: Aug 2012
Default 10-21-2012, 05:59 PM

bump
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-21-2012, 08:19 PM

The world seems to work fine for me, and the variables change just fine as well.

Right click the variable at the top of the method, and click "watch this variable" to see it change in real time.

The only problem I see with the world is the fact that there's no mechanic to make the dial go specifically to the number specified, meaning that the user has to think of differences instead of values. I added one which makes the lock turn to the number entered, so that each number can be tried sequentially instead of entering 1 or -1 in every time.

The other problem is that there's no indication that the user has entered the correct number. You should add something like making the lock move or say "click" when the right number is entered.
Attached Files
File Type: a2w lock.a2w (208.7 KB, 6 views)


(')>
   
Reply With Quote
Old
CaptainLizard
Junior Member
 
Status: Offline
Posts: 11
Join Date: Aug 2012
Default 10-21-2012, 09:26 PM

hmm That's odd because when I made the world, I watched every variable change and it worked. But every time I've tried to run it or when my teacher tried to show it to the class, it hasn't worked. Which also implies that he had it working whenever he was grading it. But as of late, I can't get variables to work in any of my assignments, including this one that I'm redoing for the Chapter 7 exercise, like the Clock Exercise in Chapter 7 (Exercise 10), which asks you use the hour of AM or PM and the minute of hour functions to set the values for the hour and minute hands. I'll post that world when I complete the required methods.
Thanks for the help though

EDIT: Again, I loaded your example, and the variables don't change. I've entered the whole combination and even some random numbers to try to get something to change but I get nothing. -__-

Last edited by CaptainLizard; 10-21-2012 at 09:47 PM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-21-2012, 09:51 PM

If the variables aren't working, it's possible that it's because of a bug which makes local (method-level) variables go unrecognized.

Just change all the variables to global (world-level) ones and change the methods to use them accordingly. I posted another example with all the global variables made, but you'll need to make the methods use them yourself.

As for the way the numbers were made, I just made an extra variable (moveNumber) which subtracts itself from the number the user enters, leaving only the amount that the dial needs to move in order to move from its current position to the requested one.
Attached Files
File Type: a2w lock.a2w (208.7 KB, 8 views)


(')>
   
Reply With Quote
Old
CaptainLizard
Junior Member
 
Status: Offline
Posts: 11
Join Date: Aug 2012
Default 10-21-2012, 10:37 PM

THANK YOU SO MUCH!!
I figured it was a glitch, but I didn't know how to create global variables until I found them in the properties! Also, I checked back with the book, turns out we don't learn variables until Chapter 10! If i wasn't ahead already, I am now! Thanks again for the help. This problem has been bugging me for awhile.
   
Reply With Quote
Reply

Tags
2.2, alice, project, variables

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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.