I am working on this project that requires me to set a variable to two different thing. I have been working with scratch for a long time and I know that you can't do this.
In coding I am trying to say:
( I am going to do it in text because it is really long)
When I revive Start
Forever
Forever If Problem > 2 and Problem Time = 0
If Problem = 3
Set Problem 2 to 4 OR 5
If Problem = 4
Set Problem 2 to 5 OR 3
If Problem = 5
Set Problem 2 to 3 OR 4
What is the easiest way to take out those OR s and put something else in. I will think on it but it is a hard topic. My I release the beta for my game I will post the link so you can see what I am using the script for.
Offline
Use a list. It's like a variable, but it can hold multiple numbers at a time. Go to the Variables tab, and select "Make a list". You can then add all the numbers using the new blocks it gives you.
Offline
Yeah, if you use a list, you can set multiple "variables"
Offline
I guess I didn't make things clear. All the code is doing is picking between 2 things to set the variable. Either 3 or 4, 4 or 5, and 3 or 5. I can do two of them with the pick random but the 3 or 5 one I can't cause I don't want it to be 4. The list won't help me their cause it will do the same thing.
Here is the screen shot of what I have I just need to fix the middle one somehow.![]()
Last edited by avatarl8 (2009-12-21 13:01:32)
Offline
This is kinda complicated, but if it's really important you can use this method.
1.Make a list called "Problem 4 Useable Numbers" (Or something random, it doesn't matter
)
2.Add 3 and 5 to the list, then make a variable called "RP" (Random Picker)
3. Use this script:
if Problem equals 3
set RP to pick random 1 to 2
set Problem 2 to item RP of Problem 4 Useable Numbers
end if
I hope that helped
Offline
Never mind I found an easier way of doing it.
Here it is:![]()
This is one of the most challenging programs I have ever made.
What this script is doing is creating a random problem when a timer goes off. I have 14 scripts for one sprite.
ok, now I have to tell all of you what this script is for. I am making a game where you own an internet provider company. You have to keep your cable lines up and running so your customers are happy. You keep your server running and they are happy. That script was for the problem two. There can only be problems with your company at a time. You have to fix it. That script randomly picks a problem to occur after 10 secs has elapsed from the first problem starting. It has taken me a few days to get this far so thanks for the help with little speed bump.
Last edited by avatarl8 (2009-12-21 16:09:24)
Offline
OK, so here's how you use 'pick random' to get 3 OR 5:
((pick random (1) to (2) )*2)+1.
What this does, is make it either 1 or 2. Then, it doubles it, to be 2 or 4.
Finally, it adds one, to be 3 or 5.
To get other ### or ### formulas:
Use (pick random (1) to (2) ), always with one and 2.
Multiply it by the difference between the two numbers.
Then add the difference between the difference between the two numbers, and the lowest number.
In this case, 5-3=2, so we multiply by 2. (since 5 & 3 are the numbers, 2 is the difference)
3-2=1, so we add 1. (since 3 is the lowest number, and 2 is the difference)
Another example:
If we want 6 OR 10:
We start with (pick random (1) to (2) ).
6-10=4. So, we multiply it by 4: (pick random (1) to (2) )*4
6-4=2, so we add 2: ((pick random (1) to (2) )*4)+2.
As you can see, if it is first one, then 1*4=4, and 4+2=6...
If it is initially 2, then 2*4=8, and 8+2=10!
Hope this helps.
Last edited by billyedward (2009-12-24 03:29:06)
Offline
Id just use a list and trial and error. But the ones already suggest are good aswell.
Offline