Home   Help Search Login Register  

Author Topic: Random X  (Read 533 times)

0 Members and 1 Guest are viewing this topic.

marcus3

  • Guest
Random X
« on: 30 Dec 2005, 19:07:11 »
i have a script ( will show in post) that is supposed to make the troops have some idle talk, i want it to be so they say differnt things, anywas here is the script

Code: [Select]
_yada = random 3


?(_yada == 1) : goto "talk1"

?(_yada == 2) : goto "talk2"

?(_yada == 3) : goto "talk3"


#talk1

titlecut ["Soldier - Man its cold!","PLAIN DOWN",1]
?(talk == 0) : exit

~4

titlecut ["Soldier - Stop whineing!","PLAIN DOWN",1]

?(talk == 0) : exit
~4

exit


#talk2

titlecut ["Soldier - I wonder when this will all be over....","PLAIN DOWN",1]

?(talk == 0) : exit
~4

titlecut ["Soldier - When the russian dogs are gone!","PLAIN DOWN",1]

?(talk == 0) : exit
~4

exit


#talk3

titlecut ["Soldier - I am hungrey","PLAIN DOWN",1]

?(talk == 0) : goto "fix"
~4

titlecut ["Soldier - Dont you ever think about something else then food?","PLAIN DOWN",1]

?(talk == 0) : goto "fix"

~4

exit


#fix


 
exit
the talk varible is used so when u the player walks away the talking stops
anywas, i keep getting the top message, i have tryed doing this befor but, i still cant get it :P
thanks

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Random X
« Reply #1 on: 30 Dec 2005, 19:19:40 »
Random doesn't return an exact integer number (well, very rarely).

You need to use mod to strip away the decimal portion to arrive at a whole integer.

Instead of:
Code: [Select]
_yada = random 3

?(_yada == 1) : goto "talk1"

?(_yada == 2) : goto "talk2"

?(_yada == 3) : goto "talk3"
Try:

Code: [Select]
#top
_rnum = random 4 ; _yada = _rnum - (_rnum mod 1)

?(_yada == 1) : goto "talk1"

?(_yada == 2) : goto "talk2"

?(_yada == 3) : goto "talk3"

?(_yada == 4) : goto "top"

Something like that anyway



Planck
« Last Edit: 30 Dec 2005, 19:20:37 by Planck »
I know a little about a lot, and a lot about a little.

marcus3

  • Guest
Re:Random X
« Reply #2 on: 30 Dec 2005, 19:25:54 »
awsome, it works, thanks planck! ;D