Home   Help Search Login Register  

Author Topic: setTriggerStatements  (Read 1776 times)

0 Members and 1 Guest are viewing this topic.

Offline Mysterious Hu

  • Members
  • *
setTriggerStatements
« 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  :-[

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: setTriggerStatements
« Reply #1 on: 30 Mar 2009, 15:40:20 »
Looks fine to me. Rather depends how you define _aLocalVariable, I think.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mysterious Hu

  • Members
  • *
Re: setTriggerStatements
« Reply #2 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:
« Last Edit: 31 Mar 2009, 17:57:44 by Spooner »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: setTriggerStatements
« Reply #3 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, ""]
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)