OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: The-Architect on 24 Jun 2004, 18:49:44
-
How can I turn a script off via a trigger in the editor?
Here's what I'm doing.
I have a helo flying from a dirt strip. I'm using Vektorboson's helidust script.
The dust on the dirt strip is, well, dirt colour.
My helo will finish up on grass.
Now I tried just having two of the same scripts with differewnt names. This half worked. When the helo hit the trigger to exec the grass script, it did indeed create grass dust. However I still have the dirt dust along side it.
Any ideas on ending the script, Via a Trigger?
Cheers. ;D
-
I had a similar problem, except mine were a lot trickier since I could not use global booleans and the script was supposed to run more than once.
However, yours should be a piece of cake.
Somewhere in the loop of your script that creates dust, put in a global boolean condition, like:
? ArmstyIsTheKing == True : exit
And in a trigger put:
ArmstyIsTheKing = true
:beat: *Gets Shot* :beat:
-
I modified heli_dust by Vektorboson, now you can choose maximum 2 different colours on one map. In the example I change NAM dust into GRASS dust.
I added the bolean othercolor = true/false to end the script when you enter a new area (other texture)
How to change the color dust.
You need a trigger that covers the area with the different groundtexture. . If you want to cover other pieces of ground that's on the shore, don't worry your trigger may cover the sea, the script will still change the dust in waterspashes when you fly oversea.
Example : place a helicopter and name it helo1
Put this in your trigger
ACTIVATION : WEST, Repeatedly
Condition : Heli1 in thislist
On activation : othercolor = true; [heli1,"NAM"] exec "heli_dust+.sqs"
On deactivation : othercolor = true; [heli1,"GRASS"] exec "heli_dust+.sqs"
Here's the modified heli_dust script
heli_dust+.sqs
; Heli Dust+ script by Vektorboson; modified by Blanco
; see _sensor and _calcH for above sea level calculation!
; execute just
; [name of the chopper, colour of dust] exec "heli_dust+.sqs"
;Valid colours are : "GRASS","SAND","DUST","DESERT","NAM" and "SNOW"
_chopper = _this select 0
_dust = _this select 1
~1
othercolor = false
?_dust == "GRASS": goto "1"
?_dust == "SAND" :goto "2"
?_dust == "DUST" :goto "3"
?_dust == "DESERT" :goto "4"
?_dust == "NAM" : goto "5"
?_dust == "SNOW" : goto "6"
#1
HDCOLOR = [[0.35,0.35,0.3,0], [0.2, 0.2, 0.1, 0.5],[0.2, 0.27, 0.15, 0]]
goto "next"
#2
HDCOLOR = [[0.35,0.35,0.3,0],[0.35,0.35,0.3,0],[0.6, 0.57, 0.5, 0.5],[0.5, 0.47, 0.4, 0]]
goto "next"
#3
HDCOLOR = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.4,0.4,0.4,0.7], [0.65, 0.6, 0.5, 0]]
goto "next"
#4
HDCOLOR = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.7,0.7,0.65,1], [0.65, 0.6, 0.5, 0]]
goto "next"
#5
HDCOLOR = [[ 0.4,0.3, 0.2,0.2], [ 0.4,0.3, 0.2,0.25], [0.4,0.3, 0.2, 0.3], [ 0.4, 0.3, 0.2, 0.1]]
goto "next"
#6
HDCOLOR = [[0.95,0.95,0.95,0.2], [0.95,0.95, 0.95,0.4], [0.95 ,0.95,0.95,0.4], [1,1,1,0.1]]
goto "next"
#next
HDCOLORWATER = [[0.8,0.8,0.9,0],[0.9,0.9,1,0.7],[0.8,0.8,0.9,0],[0.8,0.8,0.9,0]]
_null = "scalar bool array string 0xfcffffef"
private ["_sensor"];
_sensor = "EmptyDetector" createVehicle [0,0,0]
_calcH = {private["_result"]; _sensor setpos [getpos _chopper select 0, getpos _chopper select 1, 0]; _result = getpos _sensor select 2; _result};
?format["%1",HDSIN ] == _null: HDSIN = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [sin (7.2*_i)*15]; _i = _i+1;}; _result}
?format["%1",HDCOS ] == _null: HDCOS = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [cos (7.2*_i)*15]; _i = _i + 1}; _result}
; these are color prefabs! You may adjust or add some new if you like!
; color for this helictoper
_icolor = HDCOLOR
_repeat = true
_lifetime = 2
_shape = "cl_basic"
_color = _icolor
; here comes all the visual part!
#repeat
?(getpos _chopper select 2) < 30 && speed _chopper < 120 && isEngineOn _chopper : goto "loop"
?othercolor : goto "exit"
~0.1
goto "repeat"
#loop
_pos = getpos _chopper
_x = _pos select 0
_y = _pos select 1
_i = 0
#l1
?othercolor : goto "exit"
_vel = [HDSIN select _i, HDCOS select _i, 0]
_size1 = random 2
_size2 = random 3 + 3
_size = [_size1, _size2]
drop [_shape, "", "Billboard", _lifetime, _lifetime, [_x, _y, 0], _vel, 0, 0.2, 0.157, 0.001, _size, _color, [0], 0.1, 0.2, "", "", ""]
_i = _i + 1
?_i < 50: goto "l1"
~0.01
_color = _icolor
_shape = "cl_basic"
?othercolor : goto "exit"
?abs(_this call _calcH) < 3: _color = HDCOLORWATER; _shape = "cl_water"
?(getpos _chopper select 2) < 30 && speed _chopper < 120 && isEngineOn _chopper: goto "loop"
?_repeat && alive _chopper : goto "repeat"
#exit
deletevehicle _sensor
exit
-
Diddn't work "Armsty".
Where exactly would you suggest putting it?
Blanco, what do you mean? there is the ability to have any colour with Vektorboson's script. Even more than the pre-sets.
-
If you gimme that script so I can look at it I'll sort it out for ya. :-*
:beat: *Gets Shot* :beat:
-
I don't understand a word of that Blanco. How does it now what the new texture colour is?
Her's the script Armstrong,
; Heli Dust script by Vektorboson
; see _sensor and _calcH for above sea level calculation!
; execute just
; MyHeli exec "effects\heli_dust.sqs"
_null = "scalar bool array string 0xfcffffef"
private ["_sensor"];
_sensor = "EmptyDetector" createVehicle [0,0,0]
_calcH = {private["_result"]; _sensor setpos [getpos _this select 0, getpos _this select 1, 0]; _result = getpos _sensor select 2; _result};
?format["%1",HDSIN ] == _null: HDSIN = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [sin (7.2*_i)*15]; _i = _i+1;}; _result}
?format["%1",HDCOS ] == _null: HDCOS = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [cos (7.2*_i)*15]; _i = _i + 1}; _result}
; these are color prefabs! You may adjust or add some new if you like!
HDCOLORGRASS = [[0.35,0.35,0.3,0], [0.2, 0.2, 0.1, 0.5],[0.2, 0.27, 0.15, 0]]
HDCOLORSAND = [[0.35,0.35,0.3,0],[0.35,0.35,0.3,0],[0.6, 0.57, 0.5, 0.5],[0.5, 0.47, 0.4, 0]]
HDCOLORDUST = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.4,0.4,0.4,0.7], [0.65, 0.6, 0.5, 0]]
HDCOLORDESERT = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.7,0.7,0.65,1], [0.65, 0.6, 0.5, 0]]
HDCOLORWATER = [[0.8,0.8,0.9,0],[0.9,0.9,1,0.7],[0.8,0.8,0.9,0],[0.8,0.8,0.9,0]]
; color for this helictoper
_icolor = HDCOLORSAND
_repeat = true
_lifetime = 2
_shape = "cl_basic"
_color = _icolor
; here comes all the visual part!
#repeat
@(getpos _this select 2) < 30 && speed _this < 120 && isEngineOn _this
#loop
_pos = getpos _this
_x = _pos select 0
_y = _pos select 1
_i = 0
#l1
_vel = [HDSIN select _i, HDCOS select _i, 0]
_size1 = random 2
_size2 = random 3 + 3
_size = [_size1, _size2]
drop [_shape, "", "Billboard", _lifetime, _lifetime, [_x, _y, 0], _vel, 0, 0.2, 0.157, 0.001, _size, _color,
_i = _i + 1
?_i < 50: goto "l1"
~0.01
_color = _icolor
_shape = "cl_basic"
?abs(_this call _calcH) < 3: _color = HDCOLORWATER; _shape = "cl_water"
?(getpos _this select 2) < 30 && speed _this < 120 && isEngineOn _this: goto "loop"
?_repeat && alive _this : goto "repeat"
-
???
How can I explain this? :-\
I'm sure it works because Scorpion've used it in a NAM mission...
The script doesn't know the color of the groundtexture, you have to define the colors in the exec line (2th parameter)
In your case , place a trigger over the dirtstrip where your chopper (heli1) flies with :
ACTIVATION : WEST, Repeatedly
Condition : Heli1 in thislist
On activation : othercolor = true; [heli1,"DUST"] exec "heli_dust+.sqs"
On deactivation : othercolor = true; [heli1,"GRASS"] exec "heli_dust+.sqs"
When the chopper leave the area (trigger) the DUSTcolor will change in GRASS color, the script exits first and runs again (with ~1 sec delay) with a different color (GRASS)
You can place more triggers on other area's with dirt.
-
; Heli Dust script by Vektorboson
; see _sensor and _calcH for above sea level calculation!
; execute just
; MyHeli exec "effects\heli_dust.sqs"
_null = "scalar bool array string 0xfcffffef"
private ["_sensor"];
_sensor = "EmptyDetector" createVehicle [0,0,0]
_calcH = {private["_result"]; _sensor setpos [getpos _this select 0, getpos _this select 1, 0]; _result = getpos _sensor select 2; _result};
?format["%1",HDSIN ] == _null: HDSIN = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [sin (7.2*_i)*15]; _i = _i+1;}; _result}
?format["%1",HDCOS ] == _null: HDCOS = call {private["_i","_result"]; _result = []; _i = 0; while "_i < 50" do {_result = _result + [cos (7.2*_i)*15]; _i = _i + 1}; _result}
; these are color prefabs! You may adjust or add some new if you like!
HDCOLORGRASS = [[0.35,0.35,0.3,0], [0.2, 0.2, 0.1, 0.5],[0.2, 0.27, 0.15, 0]]
HDCOLORSAND = [[0.35,0.35,0.3,0],[0.35,0.35,0.3,0],[0.6, 0.57, 0.5, 0.5],[0.5, 0.47, 0.4, 0]]
HDCOLORDUST = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.4,0.4,0.4,0.7], [0.65, 0.6, 0.5, 0]]
HDCOLORDESERT = [[0.4,0.4,0.4,0],[0.6,0.6,0.6,0],[0.7,0.7,0.65,1], [0.65, 0.6, 0.5, 0]]
HDCOLORWATER = [[0.8,0.8,0.9,0],[0.9,0.9,1,0.7],[0.8,0.8,0.9,0],[0.8,0.8,0.9,0]]
; color for this helictoper
_icolor = HDCOLORSAND
_repeat = true
_lifetime = 2
_shape = "cl_basic"
_color = _icolor
; here comes all the visual part!
#repeat
@(getpos _this select 2) < 30 && speed _this < 120 && isEngineOn _this
#loop
_pos = getpos _this
_x = _pos select 0
_y = _pos select 1
_i = 0
#l1
_vel = [HDSIN select _i, HDCOS select _i, 0]
_size1 = random 2
_size2 = random 3 + 3
_size = [_size1, _size2]
drop [_shape, "", "Billboard", _lifetime, _lifetime, [_x, _y, 0], _vel, 0, 0.2, 0.157, 0.001, _size, _color, [0], 0.1, 0.2, "", "", ""]
_i = _i + 1
; ATTENTION ARCHITECHT!!! HERE IS THE LINE!!!
? BOOLEAN == TRUE : EXIT
; END OF LINE
?_i < 50: goto "l1"
~0.01
_color = _icolor
_shape = "cl_basic"
?abs(_this call _calcH) < 3: _color = HDCOLORWATER; _shape = "cl_water"
?(getpos _this select 2) < 30 && speed _this < 120 && isEngineOn _this: goto "loop"
?_repeat && alive _this : goto "repeat"
Try that. You have to check with Vektorboson if it's OK with him that you edit his script.
:beat: *Gets Shot* :beat:
-
Didn't work Armstrong. I got this error message,
'Boolean == TRUE |#|': Error ==: TypeAny, expected Number, String, Object, Side, Group
I also got error messages similar when trying the Blanco idea.
:(
Surely there must be a simpler way to force a script to terminate?
-
I'm sure my example works, I can make you a test till tuesday.
note :
There were 2 typos in the exec line...
helidust+sqs instead of heli_dust+.sqs
About...
?Bolean == true
He means you have to put a bolean there to stop the script
eg :
?stopscript : exit
And then in a trigger or waypoint in the onactivation field :
Stopscript = true
Once Stopscript is set true the script exits.
I do the same, the difference is that my bolean is named othercolor and you can run the same script again , this time with another dust colour
Valid colours are : "GRASS","SAND","DUST","DESERT","NAM" and "SNOW"