Actionscript question..
- Xipp
-
Xipp
- Member since: Jan. 1, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
How do I make a random value be limited?
What?
Let me explain further..
I want my random script to pick either the number 1 or 2.
This is what I´m writing:
random(2);
Then it picks either 0, 1 or 2.
I do only want it to pick 1 or 2.
So.. You want us to explain how to make the random script choose between the numbers 1 or 2, instead of 0, 1 or 2?
Exactly! You´re pretty smart, my friend!
- AcidicFlame
-
AcidicFlame
- Member since: Apr. 15, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
Try this:
myNum = Math.round(1+Math.random());
:D
- Zielak
-
Zielak
- Member since: Sep. 21, 2005
- Offline.
-
- Forum Stats
- Member
- Level 17
- Game Developer
At 7/20/07 10:40 AM, Xipp wrote: random(2);
random(1);
picks number from 0 to 1
random(1)+1;
picks number 1 to 2
:]
- Hoeloe
-
Hoeloe
- Member since: Apr. 29, 2004
- Offline.
-
- Forum Stats
- Member
- Level 37
- Game Developer
Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------
- Hoeloe
-
Hoeloe
- Member since: Apr. 29, 2004
- Offline.
-
- Forum Stats
- Member
- Level 37
- Game Developer
its non iclusive btw, started posting before the last post was made...
Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------
- deafeningsilence5
-
deafeningsilence5
- Member since: Mar. 29, 2006
- Offline.
-
- Forum Stats
- Member
- Level 16
- Blank Slate
At 7/20/07 10:53 AM, Hoeloe wrote: OR
random(2) + 1;
That makes 1, 2, or 3.
XBL: Foar The Lulz
>:(
- Xipp
-
Xipp
- Member since: Jan. 1, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Thanks everyone! Your help solved my problem!
So.. You don´t need our help anymore..?
Don´t worry! I´ll properly ask for more help soon!
Thank god!.. So.. It´s done now, huh..?
Yeah.. It is. Your advice have really been good to me, but I think it´s time to say good bye.. I´ll miss you guys, but we can´t keep posting in this topic.. There´s other topics that need posts.. Other people who need help.. Go. Go, help somebody..
That.. was really touching..
Yeah, I know.. Thanks..
You´re welcome!
Thanks! Good bye! Hahaha..!
Haha..
Hahaha..
Ha... ha
Ha..
- Zielak
-
Zielak
- Member since: Sep. 21, 2005
- Offline.
-
- Forum Stats
- Member
- Level 17
- Game Developer
At 7/20/07 11:19 AM, Xipp wrote: Ha... ha
Ha..
Haha you too :] .
- Xipp
-
Xipp
- Member since: Jan. 1, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Haha, you´re funny!
You too
Don´t say that in public!! Haha!
Hahaha!
Haha!
Hahaha!
Haha!
Hahaha!
Haha!
Hahaha. No.
- LegolasFIN
-
LegolasFIN
- Member since: May. 7, 2004
- Offline.
-
- Forum Stats
- Member
- Level 23
- Blank Slate
- trig1
-
trig1
- Member since: Oct. 4, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Blank Slate
- Xipp
-
Xipp
- Member since: Jan. 1, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
I think you should try it! You´ll like it!
- ninjitsuwarrior
-
ninjitsuwarrior
- Member since: Apr. 28, 2006
- Offline.
-
- Forum Stats
- Member
- Level 24
- Game Developer
Maybe the test to prove it:
onEnterFrame=function(){trace(Math.ceil(
Math.random()*2))};
And only the number:
Math.ceil(Math.random()*2);
Thanks ninjitsuwarrior!
No problem!
Really?
Yeah...
Omg, i like you!
Aww, thank you! That's nice!
Haha
Haha
Not funny...
- Xipp
-
Xipp
- Member since: Jan. 1, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Ok, I´ve tried all of your ideas but none of them worked.
So, what do you want us to?
I want you guys to tell me what I does wrong, by showing you the hole script for that part of my game. Then I hope you will help me solve my problem.
Sounds cool, but why did you tell us that "we helped solving your problem" int the first place?
Yeah, I was so sure that your ideas would solve my problem that I wrote it before I even tried it..
Lol, that wasn´t too smart!
I know..
Anyway, show us your script and we´ll try to help you.!
Here´s the script:
onClipEvent (load) {
// Normal weight
if (_root.fat>50 && _root.fat<150) {
if (_root.kt>0 or _root.kt == 0) {
_root.ktr = random(2)+1;
if (_root.ktr == 1) {
this.gotoAndPlay(1);
}
if (_root.ktr == 2) {
this.gotoAndPlay(2);
}
}
if (_root.kt>100 or _root.kt == 100) {
_root.ktr == random(3)+1;
if (_root.ktr == 3) {
this.gotoAndPlay(3);
}
if (_root.ktr == 4) {
this.gotoAndPlay(4);
}
}
if (_root.kt>300 or _root.kt == 300) {
_root.ktr == random(4)+1;
if (_root.ktr == 5) {
this.gotoAndPlay(5);
}
if (_root.ktr == 6) {
this.gotoAndPlay(6);
}
}
if (_root.kt>600 or _root.kt == 600) {
_root.ktr == random(5)+1;
if (_root.ktr == 7) {
this.gotoAndPlay(7);
}
if (_root.ktr == 8) {
this.gotoAndPlay(8);
}
}
if (_root.kt>2000 or _root.kt == 2000) {
_root.ktr == random(6)+1;
if (_root.ktr == 9) {
this.gotoAndPlay(9);
}
if (_root.ktr == 10) {
this.gotoAndPlay(10);
}
}
}
}
NOTE: I want the movieclip to go to a specific frame when ktr is for example. 3.. Don´t notice the other stuff. The only important thing is the ktr´s.
I hope you can help me..
- AcidicFlame
-
AcidicFlame
- Member since: Apr. 15, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
You can try this if you want:
onClipEvent(load){
if (_root.fat>50 && _root.fat<150) {
if (_root.kt>=2000) {
_root.ktr = Math.round(9+Math.random());
}else if(_root.kt>=600){
_root.ktr = Math.round(7+Math.random());
}else if(_root.kt>=300){
_root.ktr = Math.round(5+Math.random());
}else if(_root.kt>=100){
_root.ktr = Math.round(3+Math.random());
}else if(_root.kt>=0){
_root.ktr = Math.round(1+Math.random());
}
this.gotoAndStop(_root.ktr);
}
}
:D



