Home   Help Search Login Register  

Author Topic: Is there a better way of doing this?  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

Offline CharlieReddog

  • Members
  • *
Is there a better way of doing this?
« on: 09 Sep 2007, 12:11:21 »
Trying to work out a better way perhaps of doing this, maybe using the format function , but I'm not sure how it would work.
what I'd like is something like [] exec "Logic(format[resultnumber]).sqs" to cut down on all the crap.

Code: [Select]
_intRndLoc=random 11
;_intrndLoc=4
_intRndWth=random 6

?_intRndLoc>10:goto "11"
?_intRndLoc>9:goto "10"
?_intRndLoc>8:goto "9"
?_intRndLoc>7:goto "8"
?_intRndLoc>6:goto "7"
?_intRndLoc>5:goto "6"
?_intRndLoc>4:goto "5"
?_intRndLoc>3:goto "4"
?_intRndLoc>2:goto "3"
?_intRndLoc>1:goto "2"
?_intRndLoc<=1:goto "1"

#1
[] exec "Logic1.sqs"
goto "Weather"
#2
[] exec "Logic2.sqs"

goto "Weather"
#3
[] exec "Logic3.sqs"

goto "Weather"
#4
[] exec "Logic4.sqs"

goto "Weather"
#5
[] exec "Logic5.sqs"

goto "Weather"
#6
[] exec "Logic6.sqs"

goto "Weather"
#7
[] exec "Logic7.sqs"

goto "Weather"
#8
[] exec "Logic8.sqs"

goto "Weather"
#9
[] exec "Logic9.sqs"

goto "Weather"
#10
[] exec "Logic10.sqs"

goto "Weather"
#11
[] exec "Logic11.sqs"

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Is there a better way of doing this?
« Reply #1 on: 09 Sep 2007, 12:32:42 »
Code: [Select]
;Random between 0 and 10.9
_intRndLoc=random 10.9

;Now we get rid of decimals, the result is a random beteen 0 and 10 plus 1 (1 -> 11)
_intRndLoc = 1 + _intRndLoc - (_intRndLoc % 1)

[] exec format["Logic%1.sqs", _intRndLoc]

Offline CharlieReddog

  • Members
  • *
Re: Is there a better way of doing this?
« Reply #2 on: 09 Sep 2007, 17:11:02 »
 :clap:

Thanks Mandoble, that just made my scripts way way way smaller.

Offline CharlieReddog

  • Members
  • *
Re: Is there a better way of doing this?
« Reply #3 on: 09 Sep 2007, 17:55:01 »
Just realised, I don't really need the format there, I need it here.

Code: [Select]
_intLgc=_this select 0
_strLocX= format["getpos lgc_%1 select 0",_intlgc]

Unfortunately, this doesn't work, nor does
Code: [Select]
_intLgc=_this select 0
_strLocX= getpos format["lgc_%1 ",_intlgc] select 0

What have I cocked up now?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Is there a better way of doing this?
« Reply #4 on: 09 Sep 2007, 22:03:22 »
Code: [Select]
_strLocX= getpos (call format["lgc_%1 ",_intlgc]) select 0

Offline CharlieReddog

  • Members
  • *
Re: Is there a better way of doing this?
« Reply #5 on: 10 Sep 2007, 10:44:44 »
Call? Never heard of it, but it works both there, and in front of the whole thing which is interesting. Thanks for your help. I've now just managed to replace 12 scripts, with 2. :good: