Alice Community  

Go Back   Alice Community > Alice 2 > Bugs and Troubleshooting

Reply
 
Thread Tools Display Modes
Incrementing/Decrementing Variables Bug
Old
zachdog6
Junior Member
 
Status: Offline
Posts: 4
Join Date: Feb 2013
Default Incrementing/Decrementing Variables Bug - 04-17-2013, 09:55 AM

As the title says, I have a problem when I try to Incrementing/Decrementing variables. That is, when I try to it will Increment/Decrement, but nothing else knows it had. When I watch the variable in game and it Increments/Decrements, the new number that it should equal is created as a separate number that the rest of the game knows nothing about.

for instance, lets say I increase a variable from 1 to 2. It will be set to 2, but a completely different 2. There will two 2 numbers in the game, and in order for the game to continue I have to set the variable from the new 2 to another two.

I'm not exactly sure how to explain this, so I hope it isn't too confusing. Please help.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 04-17-2013, 04:27 PM

Post your world so others can see what is actually going on, and state what model of Alice you are using, 2.2 2.3 or 3.1 because that information is always handy when helping. It kind of sounds like you coded something wrong though, so if you upload your world, it would be easier to help.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
zachdog6
Junior Member
 
Status: Offline
Posts: 4
Join Date: Feb 2013
Default 04-17-2013, 08:15 PM

Here you go. Watch the variable InfectionCount on the Bacteria object, then in game stay near one of the blood cells until the loading bar fills up. You will see that InfectionCount will go to one. However, if you expand the numbers menu there will two 1s. Click on the 1 that isn't selected and it will work. The methods that handled the incrementing are the Infection methods on the BloodCells.

The weird this is that it only works if you replace the Increment variable method with something that sets the variable equal to one number. For instance, if you replace the Increment Variable methods with InfectionCount = 1, then the above scenario will work the first time.

I have alice 2.3.3
Attached Files
File Type: a2w Virus.a2w (1.44 MB, 10 views)

Last edited by zachdog6; 04-17-2013 at 08:25 PM.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 04-17-2013, 08:31 PM

Well I checked it out, and it all seems to work, I really don't know what you are having trouble with though, The infectioncount increases up to 5 after I collect all the red cells, and the only other variable I see on there is your variable Tagged, so I don't know what you are having trouble with.

Example of a decent description of your problem would state what variable you are having trouble with, what is the exact purpose of that variable, what method controls that variable, what is the variable doing now compared to what you want it to do, and lastly, double check your code to make sure you did it right.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
zachdog6
Junior Member
 
Status: Offline
Posts: 4
Join Date: Feb 2013
Default 04-17-2013, 08:43 PM

Quote:
Originally Posted by sfunk View Post
Well I checked it out, and it all seems to work, I really don't know what you are having trouble with though, The infectioncount increases up to 5 after I collect all the red cells, and the only other variable I see on there is your variable Tagged, so I don't know what you are having trouble with.

Example of a decent description of your problem would state what variable you are having trouble with, what is the exact purpose of that variable, what method controls that variable, what is the variable doing now compared to what you want it to do, and lastly, double check your code to make sure you did it right.
Does the bacteria resize and reveal the other bacteria when it increments? Because that's the problem. The variable goes up, but the methods think it hasn't. If you watch the variable, then switch it to 1 manually you will see that the bacteria resizes and one more gets revealed. However, if it gets switched to 1 by the increment method this doesn't happen. When the increment method switches it to 1 you will also see that there are two 1s, and it you switch it to the 1 that isn't selected that it works.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 04-18-2013, 03:22 PM

Well I got it to work. I made a World.number variable and just named it infectioncount for simplicity. I then went and replaced all the methods that used the number variable you created, which in return, worked. I think having the number variable you created being part of the object's properties made it too difficult for Alice to call for that variable outside of that object's own method. So just use a world variable next time, it will save you a lot of headache. I also just brought the resize method into it's own event so it would constantly loop that method without any interruption from the other parts of your method. You should be able to keep it where you have it, I just wanted to put it there so I could watch it easier. Here is my version of it so you can see what I did.
Attached Files
File Type: a2w Virus.a2w (1.44 MB, 2 views)


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
zachdog6
Junior Member
 
Status: Offline
Posts: 4
Join Date: Feb 2013
Talking 04-18-2013, 08:08 PM

Thank you.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 04-19-2013, 02:51 PM

You're welcome. Glad to help.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.