Home   Help Search Login Register  

Author Topic: Trigger syntax and other problems ;-)  (Read 613 times)

0 Members and 2 Guests are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Trigger syntax and other problems ;-)
« on: 11 Feb 2004, 17:45:40 »
ok, you scripting guru's out there, i'll tell ya what i have and then where the problem is.

first i have a trigger, Cond: true On Act: tankdead = 0
it's an init trigger which sets the global variable to 0 at mission start

second, i have a trigger which calls a script from mission start, so it's Cond is also: true, in the On Activation field i put: [this] exec "tanksdestroyed.sqs"

this will call the following script, which is supposed to get the dammage status of 4 tanks.

;tanksdestroyed.sqs

#loop
_dam1 = getdammage T1
_dam2 = getdammage T2
_dam3 = getdammage T3
_dam4 = getdammage T4
?(_dam1 >= 0.7) AND (_dam2 >= 0.7) AND (_dam3 >= 0.7) AND (_dam4 >= 0.7): goto "next"
?(_dam1 >= 0.7): T1 setdammage 1
?(_dam2 >= 0.7): T2 setdammage 1
?(_dam3 >= 0.7): T3 setdammage 1
?(_dam4 >= 0.7): T4 setdammage 1
~2
goto "loop"

#next
tankdead = 1
deletevehicle T1
deletevehicle T2
deletevehicle T3
deletevehicle T4
exit

;end of Script

as you m8 see, the scripts get the dammage status of each Tank (T1 to T4), when a tank is dammaged more than 0.7 it will destroy it completely. As long not ALL tanks are dammaged that heavy, script should loop back to the beginning, and when ALL 4 tanks are dammaged more than 0.7 it should delete the tanks and set the global variable "tankdead" to 1.

as far as good, till now all seems to work perfectly (at least i didn't got any error messages)

next thing i have is another trigger which should createvehicle Inf's and/or tanks (these scripts are already tested out and work without any error so i wont bother you to post these scripts too)
The trigger Cond is: (tankdead == 1) AND (time >= 100)
This should (as far as i know) activate the trigger when tankdead is set to 1 by the script above AND the mission already runs at least 100 seconds. in the on activation box i just call the script which createvehicles the stuff i need.

Now to the error i got. When the tanks are destroyed it says ¦#¦ error in expression
but no further information in which line trigger or script it is.

I've checked all the syntax i already know, especially the calls for these createvehicle scripts so i can say, the error must be somewhere else.

Since i didn't add other scripts or triggers or anything else except the things above, the error must be somewhere in there, but i can't figure out where.

If you guys could take a look onto it i would be very happy...

thx alot guys

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Trigger syntax and other problems ;-)
« Reply #1 on: 11 Feb 2004, 17:52:14 »
I think 'time' is a scripts only variable, it checks the time when the script launches. Not sure though.

:beat: *Gets Shot* :beat:

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #2 on: 11 Feb 2004, 18:10:45 »
as far as i know the variable time is used to get the time since the mission started. It doesn't reflect daytime or something else. If i'm not wrong the variable _time is used to get the time how long a script is already runnin.

Usually i use the time variable as an easy way to end a DM or CTF time >= param1 (or is it param2?..nvm, you know what is meant)  putted in a triggers cond field.

so it means, time starts counting at 0 everytime mission is started.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Trigger syntax and other problems ;-)
« Reply #3 on: 11 Feb 2004, 18:13:01 »
oh yea, silly me ;D

:beat: *Gets Shot* :beat:

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #4 on: 11 Feb 2004, 18:16:03 »
yay...i knew something, the real armstrong didn't knew....yipieh...hmm...but it didn't took me closer to a solution  ;)

nvm...thx for your try bud  ;D

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Trigger syntax and other problems ;-)
« Reply #5 on: 11 Feb 2004, 18:22:13 »
Couple of general points about scripting while my back brain puzzles over the problem.

If you want something to happen at the start of a mission you don't need triggers.   Just whack it into init.sqs.    

If you are using a variable to switch something like a trigger on and off, your method of 0 and 1 should work.  However, its aesthetically more pleasing to use true and false.

So you could lose the "true" triggers and put this in your init.sqs

tankdead = false
[] exec "tanksdestroyed.sqs"

When you called the script from the trigger you had this

[this] exec "tanksdestroyed.sqs"

The "this" isn't really doing anything:   in a trigger, "this" refers to the condition line and in this particular case it would be passed to the script as "true".    However you don't use it in the script.   If you wanted to, you would extract it with "_this select 0".

You are correct that _time is the time elapsed since the start of the script and time is the time since the start of the mission.   Mission time and RL time do not always go at the same speed, so you can get small discrepancies, but that's not the problem here - it doesn't really matter if its 95 seconds or 105 seconds.

It seems that the tanksdestroyed script works fine on its own and the createvehicle scripts work fine on their own.   So the error is in the line

(tankdead == 1) AND (time >= 100)

I suggest you make a little test mission and check the two conditions seperately.      Change it to true/false and lose the = which isn't really doing anything so in fact the line would be:

tankdead and (time > 100)


Edit:  if that doesn't work make the error occur a couple of times and post the precise error message.    Also tell us exactly when it occurs.   Use hints to monitor the progress of the scripts and triggers so that when the error happens you know what's already happened and what hasn't.      The format command can be very useful here.    Check the online command ref if you're not familiar with it.



« Last Edit: 11 Feb 2004, 18:27:21 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #6 on: 11 Feb 2004, 18:32:10 »
thx alot macguba,

i know i could put these things into the ini.sqs and usually i put them in there  ;D
but sometimes it could be useful to have them as triggers into the editor, so you can easily switch them off to check some things. Otherwise you have to switch to a text editor, edit the init.sqs, save the file and reload the mission in the editor just to deactivate i.e. an intro seqeunce.

For the rest, i'll follow your suggestions and try all things out. I'll report success or fails as soon as possible.

thx again mac

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #7 on: 11 Feb 2004, 18:53:53 »
now i did all like you said, macguba, and i still got error message...it looks like this

|#|]: Error Invalid Number in expression

do you undestand what this means?

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Trigger syntax and other problems ;-)
« Reply #8 on: 11 Feb 2004, 19:27:30 »
You probably putan ] where there should be an ) or something.

:beat: *Gets Shot* :beat:

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Trigger syntax and other problems ;-)
« Reply #9 on: 11 Feb 2004, 22:43:58 »
Yep, it looks like there is a ] where there shouldn't be.

I use that trick with true/false  triggers too.   Very handy for testing as you say.
Plenty of reviewed ArmA missions for you to play

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #10 on: 11 Feb 2004, 23:46:29 »
yay....my eyes hurts...controlled my scripts over and over again to find this damn f****** ] in there.....found it at least...

"OfficerE" CreateUnit [[GetMarkerPos _pos select 0, getmarkerpos _pos select 1], _group, "]", 1, "LIEUTENANT"]

hay thx alot for your help guys...you're still the best...both of you (armsty and mac)  ;D

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Trigger syntax and other problems ;-)
« Reply #11 on: 11 Feb 2004, 23:54:45 »
# marks the place in the code where the error has occurred.  I have no idea why it didn't give you the full line.

"invalid number in expression" is a standard error message for when none of the other standard error messages apply.   It usually means a typo (like you had) or a syntax error.

Glad you got it fixed.  :)
Plenty of reviewed ArmA missions for you to play

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Trigger syntax and other problems ;-)
« Reply #12 on: 12 Feb 2004, 00:09:12 »
yep...tested it right now and all works fine...i'll not forget you guys in the mission credits  ;D

:edit:

i knew about that the # marks the spot, but without the line it was hard to figure out where to search  ;)
« Last Edit: 12 Feb 2004, 00:10:23 by myke13021 »