View Single Post
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 05-31-2011, 01:25 PM

Quote:
Originally Posted by gransalamandra View Post
I'm experimenting with Alice to create a recursive method.

I created a frog that is supposed to say a Fibonacci sequence (10 levels using recursiveness). A Fibonacci sequence is 1, 1, 2, 3, 5, 8, et cetera, where the two last numbers are added together to create the next number.

I created the recursive method and set two variables to record the current value and the next number, but I'm failing to pass the number to the variables.

I tried _FibNumber set value to (_FibNumber + _FibLastNumber) for the next iteration, did not work, I even tried with 3 variables but when I test, the variable doesn't change. Any ideas?

I even tried to pass a regular number value to the variables but it just keeps coming back with the original value of one
If you post your world, I could probably be more help, but from your description it seems like you are using class-level variables instead of world-level. With a class-level variable it resets itself to its original value every time you play the method. Make your variables world level instead, see if that works.


--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade

Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
   
Reply With Quote