Jump to content
Sign in to follow this  
Rejn

Simple random script

Recommended Posts

I made a simple script that generates a number randomly between 1 and 3. I tested both floor and ceil. It seems to work BUT it seems to select two numbers. For some reason when i trigger the script.. two of the groups out of three will go to the waypoint scripted rather than just one group.

Could this be due to decimal points or something?

I also tried the script without brackets... doesn't make a diff.

Quote[/b] ]

x=ceil (random 3)

~5

?(x==1): (goto "way1" else goto "weg1")

#way1

wp=plat1 addwaypoint [position ven1,20]

[plat1,1] setwaypointtype "move"

plat1 setcurrentwaypoint [plat1,1]

#weg1

~1

?(x==2): (goto "way2" else goto "weg2")

#way2

wp=plat2 addwaypoint [position ven1,20];

[plat2,1] setwaypointtype "move";

plat2 setcurrentwaypoint [plat2,1];

#weg2

~1

?(x==3): (goto "way3" else goto "weg3")

#way3

wp=plat3 addwaypoint [position ven1,20];

[plat3,1] setwaypointtype "move";

plat3 setcurrentwaypoint [plat3,1];

#weg3

~1

exit

Share this post


Link to post
Share on other sites

Problem solved... just moved the goto wegs under the condition...

seems my else coding needs practice.

Sorry for wasting space D:

Share this post


Link to post
Share on other sites
Quote[/b] ]?(x==1): (goto "way1" else goto "weg1")

wrong

try

_x = floor random 3

call compile format["wp=plat%1 addwaypoint [position ven1,20]",_x]

call compile format["[plat%1,1] setwaypointtype ""move""",_x]

call compile format["plat%1 setcurrentwaypoint [plat%1,1]",_x]

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×