OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CharlieReddog 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.
_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"
-
;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]
-
:clap:
Thanks Mandoble, that just made my scripts way way way smaller.
-
Just realised, I don't really need the format there, I need it here.
_intLgc=_this select 0
_strLocX= format["getpos lgc_%1 select 0",_intlgc]
Unfortunately, this doesn't work, nor does
_intLgc=_this select 0
_strLocX= getpos format["lgc_%1 ",_intlgc] select 0
What have I cocked up now?
-
_strLocX= getpos (call format["lgc_%1 ",_intlgc]) select 0
-
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: