Home   Help Search Login Register  

Author Topic: Script condition  (Read 958 times)

0 Members and 2 Guests are viewing this topic.

Offline IceShade

  • Members
  • *
Script condition
« on: 10 Apr 2004, 18:11:38 »
I've searched the forum, the FAQ, the scripts available, script tutorials available... No success.. On a very basic script question!

Anyways, to the point. I have a tiny little script that when West enters the trigger, it activates the script. It plays music, loops it when it finishes. But when the area has been cleared of Russians it should end.

To clear things up, this is what I have so far:

#loop
<CONDITION GOES HERE>: goto #fade
0 fademusic 0.5
playmusic "battle1";
~60
goto #loop


#fade
5 fademusic 0.0

exit

Trigger: East -- Not Present
OnActivation: Clear = true

"Clear = true" should be the condition that makes the script jump to #fade. I have no idea how to make this condition, altough it seems too easy.

Any suggestions, or suggestions to improve this simple script?

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #1 on: 10 Apr 2004, 18:22:07 »
uhm...did ya tried it with

?(clear == true): goto "fade"

imo this should it be

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #2 on: 10 Apr 2004, 18:28:12 »
Negative.. Gives a weird error.

'(Clear == true)|#|': Error ==: Type Any, expected Number,String,Object,Side,Group

That condition line sounds like it should work. But what do I know.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #3 on: 10 Apr 2004, 18:34:41 »
uhm...ok....i usually don't use true/false for my variables....i use 0 1 2 and so on..whatever needed.
Maybe this could be done easier, but hey, it works.

in your case this would work as followed:

;init.sqs

clear = 0


;fadescript.sqs

blah blah
blah blah
?(clear == 1): goto "fade"
blah blah
blah blah


Trigger: East -- Not Present
OnActivation: Clear = 1
« Last Edit: 10 Apr 2004, 18:35:08 by myke13021 »

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #4 on: 10 Apr 2004, 18:41:46 »
Cool. It works. One little problem, and what I was fearing... The condition checks if Clear == 1 every loop. That means; every 60 seconds.

Also, the loop doesn't work! When the script reaches "goto #loop" it gives an error.

'goto |#|#loop': Error Invalid number in expression


Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #5 on: 10 Apr 2004, 18:43:56 »
ya sure...wrong syntax

goto "loop"
....
.....
......

#loop

is the correct..."" for the goto...#for the label

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #6 on: 10 Apr 2004, 18:50:15 »
Awesome.

One more thingy.... Hehe. Don't slap me.

When it loops, it gives the (Clear == 1) error again, this type "Any" replaced with "Bool". Any work arounds?

Also, how can I make the condition to check every second (assuming this doesn't take up too many resources)? I want the music to end straight away (or in this case, one second :D).
« Last Edit: 10 Apr 2004, 18:50:52 by IceShade »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #7 on: 10 Apr 2004, 19:00:24 »
ok i see....here, this script should do the job...it's not tested but i think it's correct:

;fademusic.sqs

0 fademusic 0.5
#start
_a = 0
playmusic "battle1"

#loop
?(clear == 1): goto "fadeout"
_a = _a + 1
~1
?(_a == 60): goto "start"
goto "loop"

#fadeout
5 fademusic 0
exit



:edit:

this does still need the trigger:

Trigger: East -- Not Present
OnActivation: Clear = 1
« Last Edit: 10 Apr 2004, 19:01:20 by myke13021 »

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #8 on: 10 Apr 2004, 19:03:33 »
This is nuts.

Same error again.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #9 on: 10 Apr 2004, 19:04:39 »
uhm...you have a init.sqs with

clear = 0

in it?

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #10 on: 10 Apr 2004, 19:05:04 »
Indeed.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #11 on: 10 Apr 2004, 19:08:27 »
ok...last try...if this doesn't work, then i'm lost...

;fademusic.sqs

0 fademusic 0.5
#start
_a = 0
playmusic "battle1"

#loop
_clear = clear
?(_clear == 1): goto "fadeout"
_a = _a + 1
~1
?(_a == 60): goto "start"
goto "loop"

#fadeout
5 fademusic 0
exit

Offline IceShade

  • Members
  • *
Re:Script condition
« Reply #12 on: 10 Apr 2004, 19:10:10 »
I think you're lost. Same error.

Crappity crapness :/

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Script condition
« Reply #13 on: 10 Apr 2004, 19:13:11 »
indeed...i used the ?(_something == whatever): goto "somewhere" thing hundred times...ever worked

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Script condition
« Reply #14 on: 10 Apr 2004, 19:22:57 »
Have you tried:

? _clear: goto "fadeout"


Planck
I know a little about a lot, and a lot about a little.