PDA

View Full Version : Incrementing/Decrementing Variables Bug


zachdog6
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.

sfunk
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.

zachdog6
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

sfunk
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.

zachdog6
04-17-2013, 08:43 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.
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.

sfunk
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.

zachdog6
04-18-2013, 08:08 PM
Thank you.:D

sfunk
04-19-2013, 02:51 PM
You're welcome. Glad to help.