OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Mysterious Hu on 30 Mar 2009, 14:39:01

Title: setTriggerStatements
Post by: Mysterious Hu on 30 Mar 2009, 14:39:01
Hi,

My current doomed project is a seek and destroy mission in which the BLUFOR players rampage around the map capturing towns from OPFOR AI.

Each town is covered by a trigger with "BLUEFOR Present" and "this and "Land" countType thislist > 0" as its activation. OnActivation the trigger runs [] exec "MyScript.sqs" (I can't get sqfs to work  :weeping:)

MyScript.sqs creates a bunch of badguys and some triggers including a SeizedByBLUFOR trigger which I will call _myTrigger in this thread.

The problem I am having is with setTriggerStatements on _myTrigger. I cannot work out the syntax for including a bit of OnActivation code that will use a local variable created by MyScript.sqs

setTriggerStatements requires a string for the OnActivation, so I have tried creating a string and passing it to the setTriggerStatements function; something like this:

_myString = format ["%1 = 1", _aLocalVariable]
_myTrigger setTriggerStatements ["this", _myString, ""]

I recieve an error "Error Type Code Expected String"

Any help would be gratefully accepted  :-[
Title: Re: setTriggerStatements
Post by: Spooner on 30 Mar 2009, 15:40:20
Looks fine to me. Rather depends how you define _aLocalVariable, I think.
Title: Re: setTriggerStatements
Post by: Mysterious Hu on 30 Mar 2009, 17:14:05
How right you are - it is only when I start trying to work that out that I realised I was doing something very wrong. I was messing around with the wrong side of the "=" sign. Thank you very much.  :clap: :good:

After getting a "Local Variable in Global Space" Error, I finally worked out that what I need was the following:

A global variable called ObjNumber which is intialised to 0.

My "BLUFOR Present" trigger firing [1] exec "MyScript.sqs" on activation

Code: (MyScript.sqs) [Select]
_numberOfObjective = _this select 0
_ObjectiveName = format ["%1", _numberOfObjective]
_myString = format ["ObjNumber = %1",_numberOfObjective]

_capture = createTrigger ["EmptyDetector", _start]
_capture setTriggerArea [100,100, 0, false]
_capture setTriggerTimeout [60, 180, 120, false]
_capture setTriggerActivation ["WEST SEIZED", "PRESENT", false]
_capture setTriggerStatements ["this", _myString, ""]

@ Obj == _numberOfObjective

_ObjectiveName objStatus "DONE"

Exit
Of course the script does a lot more than that; however, the above is what I was having trouble with.

Again - many thanks for getting me thinking about the problem  :blink:
Title: Re: setTriggerStatements
Post by: Spooner on 31 Mar 2009, 18:04:29
Please put large blocks of code into a code block as I have done for your post above (edit your post to see how I did this).

Although your code looks like it would work, I think you are overcomplicating things a little. Remember that you can include quotes inside a string by using the alternative type of quote:
Code: (MyScript.sqs) [Select]
_numberOfObjective = _this select 0

_myString = format ["'%1' objStatus 'DONE'", _numberOfObjective]

_capture = createTrigger ["EmptyDetector", _start]
_capture setTriggerArea [100,100, 0, false]
_capture setTriggerTimeout [60, 180, 120, false]
_capture setTriggerActivation ["WEST SEIZED", "PRESENT", false]
_capture setTriggerStatements ["this", _myString, ""]