Forum Jump :

Author Message


Posts: 115
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-03-03 05:44        
     
The wiki (https://community.bistudio.com/wiki/forEach) just isn't making sense for me. So I'm trying to have multiple alarms going off without having to type a while script for each alarm so I tried to do this
_value = 1;
while {_value > 0} do {
sleep 1.7;
say3D "alarm_1";
} forEach [Alarm1, Alarm2, Alarm3, Alarm4, Alarm5];
Then I thought maybe it thought that my Alarm 2 was trying to define a group or something since thats how the wiki shows it so I changed it to this
_allAlarms == Alarm1, Alarm2, Alarm3, Alarm4, Alarm5;
_value = 1;

while {_value > 0} do {
sleep 1.7;
say3D "alarm_1";
} forEach _allAlarms;
but that didnt work.
I also tried the
_allAlarms = Alarm1...
with just the 1 equals sign but that didn't work either.
And that script is activated by a trigger to make it simple.


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 23
In-game name: Wak

 
#2 Posted at 2016-03-03 05:54        
     
  • 2 equals is for comparison, 1 equals is for assignment.
  • You need to wrap things in brackets to create arrays --> [var1, var2].
  • That's not the syntax of say3D, you need an object as a sound source.
  • You can just use the true value in while.
  • You need a separate pair of braces for forEach.

  • I'm assuming the Alarm variables are objects that are supposed to be the sound sources.
    while {true} do {
    	{
    		_x say3D "alarm_1";
    		sleep 1.7;
    	} forEach [Alarm1, Alarm2, Alarm3, Alarm4, Alarm5];
    };

    Sometimes I like to think as I started the whole "earplugs" thing.

    W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

    #define getDamage getDammage

    Advertisement


    Author Message


    Posts: 115
    Rank:


    Level: Member

    Country: us
    Location:
    Occupation:
    Age:
    In-game name:

     
    #3 Posted at 2016-03-03 06:13        
         
    I thought the forEach was what defined the object for say3D; the Alarm1, Alarm2...are the names for my objects. Also do you have to have the
    do {
    {
    }
    };
    or can you just do
    do {
    script;
    } forEach;

    That worked though, thank you *THUMBS UP*

    This post was edited by warhawk373 (2016-03-03 06:26, ago)


    Author Message


    Posts: 1189
    Rank:


    Level: Member

    Country: tr
    Location:
    Occupation: Computer Science student
    Age: 23
    In-game name: Wak

     
    #4 Posted at 2016-03-03 06:27        
         
    It defines the current element as the _x variable, it doesn't magically apply it though. Also as I told you, and as I showed in my example, yes yo do need separate braces for each of them.

    EDIT: Are you thinking that you need while for the forEach to loop? forEach is a loop by itself, so you can just remove the lines 1 and 6 from the code I posted and it will still iterate (loop) through every element of the array.

    Sometimes I like to think as I started the whole "earplugs" thing.

    W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

    #define getDamage getDammage

    Author Message


    Posts: 115
    Rank:


    Level: Member

    Country: us
    Location:
    Occupation:
    Age:
    In-game name:

     
    #5 Posted at 2016-03-03 07:10        
         
    Wait so if I have a trigger set to execute that script then all I have is
    {
            _x say3D "alarm_1";
            sleep 1.7;
        } forEach [Alarm1, Alarm2, Alarm3, Alarm4, Alarm5];
    and the alarm sound will play on a continues loop even if I leave the trigger area?


    Author Message


    Posts: 1189
    Rank:


    Level: Member

    Country: tr
    Location:
    Occupation: Computer Science student
    Age: 23
    In-game name: Wak

     
    #6 Posted at 2016-03-03 08:08        
         
    If that's the case you'd still want while. You haven't fully explained what you're exactly trying to do. Your "alarm_1" sound is 1.7 seconds long right?
    while {triggerActivated thisTrigger} do {
    	{_x say3D "alarm_1"} forEach [Alarm1, Alarm2, Alarm3, Alarm4, Alarm5];
    	sleep 1.7;
    };
    

    If you post the above in a triggers ON ACT. field, it will play the sound on all Alarms while the trigger is activated.

    Sometimes I like to think as I started the whole "earplugs" thing.

    W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

    #define getDamage getDammage

    Author Message


    Posts: 115
    Rank:


    Level: Member

    Country: us
    Location:
    Occupation:
    Age:
    In-game name:

     
    #7 Posted at 2016-03-03 08:20        
         
    So I have 5 alarm pole objects (from the CBA addon I think) around an AO and I have a trigger near a radio tower set to activate if BLUFOR units are detected by OPFOR inside the trigger area. Then when the trigger is activated is executes Alarm.sqf which is the script that I had trouble with on this post. I used sleep so that there are pauses between the alarm sound instead of it just playing the sound instantly over and over so it just sounds like a long beep. The alarm_1 is a sound file that I pulled from the Addons folder in arma 3 and put in the mission folder because I couldn't figure out how to call on it from the description.ext. But with this
    while {true} do {
    {
    sleep 0.3;
    _x say3D "alarm_1";
    } forEach [Alarm1, Alarm2, Alarm3, Alarm4, Alarm5];
    };
    
    it all worked. I just didn't know you had to have that variable before say3D and those extra {}. Also I wanted the alarm to stay on even if I leave the trigger area. I'm not sure if triggers turn to false when you leave or if you go in once then they stay true so that's why I thought I had to put the while script in there. So that the sound wont stop until the mission ends.

    The one thing that didn't go how I expected was that the alarms play in order so alarm 1 will play, then after 1.7 sec alarm 2 etc. But I fixed that by setting the sleep to 0.3 so that each alarm only has a short pause. But technically they still play in order but their spread out between about 1km so it still sounds ok.

    If you want I could create a sample mission, I think you would need CBA though for the objects that I placed.

    This post was edited by warhawk373 (2016-03-03 08:29, ago)


    Author Message


    Posts: 1189
    Rank:


    Level: Member

    Country: tr
    Location:
    Occupation: Computer Science student
    Age: 23
    In-game name: Wak

     
    #8 Posted at 2016-03-03 08:22        
         
    Well, you can get sounds from addons, just need to put an '@' symbol before it. I answered to your other post about that.

    Sometimes I like to think as I started the whole "earplugs" thing.

    W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

    #define getDamage getDammage

    Author Message


    Posts: 115
    Rank:


    Level: Member

    Country: us
    Location:
    Occupation:
    Age:
    In-game name:

     
    #9 Posted at 2016-03-03 08:39        
         
    The alarm_1 sound wasn't in an addon per-say. It was in THE arma 3 addons folder. I think that folder comes with the vanilla game, though im not 100% sure about that. Anyway, I tried to use the @ for it like this
    "@sounds_f_sfx\alarm.wss"
    but that didn't work so I just copied and pasted it into a sounds folder in the mission folder and did
    "sounds\alarm.wss"
    and that worked.
    And thats all in the description.ext

    This post was edited by warhawk373 (2016-03-03 08:45, ago)