OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ido on 15 Aug 2006, 18:08:01
-
I'm creating an ending cutscene for my first mission, I want to make the camera move along the team members and make each member report his health (with a subtitle).
I wrote the following script for each unit in the squad:
_cam camsettarget unit1
_cam camsetrelpos [-1,2,0.5]
_cam camcommit 2
@camcommitted _cam
if (getDammage unit1=0) then {
TitleText ["2 ok","PLAIN DOWN"] }
else {
_inj=_inj+1
if (getDammage unit1=1) then {
TitleText ["...","PLAIN DOWN"] }
else { TitleText ["2 Injured","PLAIN DOWN"] }
}
~2
when i run the script I get error messages for the TitleText ["2 Injured","PLAIN DOWN"] command. what did I do wrong ?
-
when assigning a value to a variable you use =, as in
_variable = value
when checking if a variable is equal to another value, you should use ==, as in
if (getDammage unit1==0) then {
TitleText ["2 ok","PLAIN DOWN"] }
and welcome to OFPEC! :)
-
when assigning a value to a variable you use =, as in
_variable = value
when checking if a variable is equal to another value, you should use ==, as in
if (getDammage unit1==0) then {
TitleText ["2 ok","PLAIN DOWN"] }
and welcome to OFPEC! :)
bah correct...
my programing is alittle rusty :)
another one, if I want the subtitle shown to show a number that is stored in a variable, should it be like this?:
TitleText ["Ok, radio back to HQ that we enliminated the threat\nwe have "_inj" men down and waiting for further instructions","PLAIN DOWN"]
or should it be like in C with the % operator (%d for integer is it ?)
-
flashpoint's proprietary scripting language shares many similarities with other languages, but this is not one of them.
you need the format command (http://www.ofpec.com/COMREF/index.php?action=list&letter=f#format).
thus the lines become
_message = format [{"Ok, radio back to HQ that we enliminated the threat\nwe have %1 men down and waiting for further instructions"}, _inj ]
TitleText [ _message, "PLAIN DOWN"]
you could create one line of titletext including the format command, but for simplicity (and sanity) it's better to separate them.
-
bedges, thanx I'll give it a try
changing the "=" to "==" didn't help I still get the following errors:
'|#|}': error invalid number in expression
'else |#|{ TitleText ["3 Injured","PLAIN DOWN"] } }': Error unknown operator
(I get this one to each one of the soldiers)
'if (_inj==0) then {|#|': Error Missing )
this is my whole code:
group player setBehaviour "STEALTH"
_inj=0
_cam = "camera" camcreate [-37037.96,93060.63,-32977.34]
_cam cameraeffect ["internal", "back"]
_camera camSetTarget [-37037.96,93060.63,-32977.34]
_camera camSetPos [9340.43,10925.47,74.68]
_camera camSetFOV 0.700
_camera camcommit 0
@camcommitted _cam
~7
_cam camsettarget player
_cam camsetrelpos [1,2,0.5]
_cam camcommit 3
@camcommitted _cam
TitleText ["Ok, I think we've got'em all\nlie down and keep covering to the front","PLAIN DOWN"]
~5
TitleText ["Team! Status report","PLAIN DOWN"]
~2
_cam camsettarget unit1
_cam camsetrelpos [-1,2,0.5]
_cam camcommit 2
@camcommitted _cam
if (getDammage unit1==0) then {
TitleText ["2 ok","PLAIN DOWN"] }
else {
_inj=_inj+1
if (getDammage unit1==1) then {
TitleText ["...","PLAIN DOWN"] }
else { TitleText ["2 Injured","PLAIN DOWN"] }
}
~2
//.
//.
//.
//the last camera script is repeating for all the squad members
_cam camsettarget player
_cam camsetrelpos [-1,2,0.5]
_cam camcommit 0
@camcommitted _cam
_message = format [{"Ok, radio back to HQ that we enliminated the threat\nwe have %1 men down and waiting for further
instructions"}, _inj ]
if (_inj==0) then {
TitleText ["Ok, radio back to HQ that we enliminated the threat\nand that we are waiting for further instructions","PLAIN DOWN"]
~6
}
else {
TitleText [_message,"PLAIN DOWN"]
~6
}
TitleText [" ","PLAIN DOWN"]
~5
_cam cameraeffect ["terminate", "back"]
camdestroy _cam
exit
-
Make sure that the if-statement is only one line, the engine can't deal with multiple lines (I think).
Also, to make a comment in the code, you have to use the semicolon (;) and you can put your comments after it. But only on that line.
Tried this and it's working:
group player setBehaviour "STEALTH"
_inj=0
_cam = "camera" camcreate [-37037.96,93060.63,-32977.34]
_cam cameraeffect ["internal", "back"]
_camera camSetTarget [-37037.96,93060.63,-32977.34]
_camera camSetPos [9340.43,10925.47,74.68]
_camera camSetFOV 0.700
_camera camcommit 0
@camcommitted _cam
~1
_cam camsettarget player
_cam camsetrelpos [1,2,0.5]
_cam camcommit 3
@camcommitted _cam
TitleText ["Ok, I think we've got'em all\nlie down and keep covering to the front","PLAIN DOWN"]
~5
TitleText ["Team! Status report","PLAIN DOWN"]
~2
_cam camsettarget unit1
_cam camsetrelpos [-1,2,0.5]
_cam camcommit 2
@camcommitted _cam
if (getDammage unit1==0) then { TitleText ["2 ok","PLAIN DOWN"] } else { _inj=_inj+1; if (getDammage unit1==1) then {TitleText ["...","PLAIN DOWN"] } else { TitleText ["2 Injured","PLAIN DOWN"] } }
~2
;the last camera script is repeating for all the squad members
_cam camsettarget player
_cam camsetrelpos [-1,2,0.5]
_cam camcommit 0
@camcommitted _cam
_message = format [{Ok, radio back to HQ that we enliminated the threat\nwe have %1 men down and waiting for further instructions}, _inj]
if (_inj==0) then { TitleText ["Ok, radio back to HQ that we enliminated the threat\nand that we are waiting for further instructions","PLAIN DOWN"]; } else { TitleText [_message,"PLAIN DOWN"] }
~6
TitleText [" ","PLAIN DOWN"]
~5
_cam cameraeffect ["terminate", "back"]
camdestroy _cam
exit
-
working !
anyone feels like testing my mission and telling me what he thinks ?
-
that's why we have a missions beta testing board ;)