Announcement

Collapse
No announcement yet.

Action with a progress bar

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Action with a progress bar

    I'm working on a mission at the moment where an action (added with "addAction") takes about 30 seconds to complete. I'd like to be able to show a progress bar up the top showing the progress... is there an easy way to do this or do you know of an example script I can have a look at?

    The closest I have found is forums.bistudio .com/showthread .php?66270-progress-bar-for-defusing-bombs but the formatting is all messed up so its a bit hard to take in. Thanks!
    sigpic

  • #2
    Re: Action with a progress bar

    Don't panic! I've had a bit of trawl through the ACE code base and it looks like this line may provide some clues:

    Code:
    [3.8,[localize "STR_ACE_SWAPBARRELACT"],true,true] spawn ace_progressbar;
    If I sort it out I'll post it up here.
    sigpic

    Comment


    • #3
      Re: Action with a progress bar

      Let me know about the outcome of that one Mech, I am kind of curious myself.

      Current ARMA Development Project: No Current Project

      "An infantryman needs a leader to be the standard against which he can judge all soldiers."

      Friend of |TG| Chief

      Comment


      • #4
        Re: Action with a progress bar

        Well putting something like:

        Code:
        [10,["Disarm Bomb"],true,true] spawn ace_progressbar;
        Displays the progress bar for ten seconds with "Disarm Bomb" above it, so I've worked out the first two arguments. Ideally there would be a callback of some sort that executes after the progress bar is finished, and a way to cancel it midway.

        I'm struggling to find the implementation in the mod code so I can work out what the other two arguments do - I can't find "ace_progressbar"... the closest is a file fnc_progress.sqf which doesn't match the signature of the call above. The ACE/ARMA documentation in general seems to be missing quite a lot unless I'm searching the wrong thing. Hmmm... some more trial and error I suppose!
        sigpic

        Comment


        • #5
          Re: Action with a progress bar

          Post on the ACE forums Mech.

          Current ARMA Development Project: No Current Project

          "An infantryman needs a leader to be the standard against which he can judge all soldiers."

          Friend of |TG| Chief

          Comment


          • #6
            Re: Action with a progress bar

            Yeah I think with callbacks I'm expecting too much and thinking too much like a javascript programmer :)

            Anyway, a bit of investigation has revealed:

            - 1st argument - time in seconds for the progress bar
            - 2nd argument - the text to display
            - 3rd argument - true if the progress bar should be cancelled when the player moves, false otherwise
            - 4th argument - not entirely sure what this is but if true the player switches back to his gun when the radio trigger executes.

            Looking at some of the ACE scripts for refuelling/repair the progress bar is just a UI element and doesn't actually do anything... for instance when refuelling all the magic is done here:

            Code:
            while {alive _repairVeh && {alive _veh} && {_veh distance _repairVeh < 15}} do {
            	if (time > _endTime) exitWith { _complete = true };
            	ADD(_i,1);
            	sleep 1;
            };
            This basically waits the given time period and if it reaches the end and the vehicles are alive and in proximity it sets "_complete" to true. Based on this my action code will look something like:

            Code:
            //
            // called by nul = [bomb_name, player_name, 10] execVM "myScript.sqf";
            //
            
            private ["_bomb", "_engineer", "_timeTaken", "_endTime", "_complete"];
            _bomb = _this select 0;
            _engineer = _this select 1;
            _timeTaken = _this select 2;
            
            // show the progress bar
            _hndl = [_timeTaken, ["Disarm Bomb"], true, false] spawn ace_progressBar;
            _endTime = time + _timeTaken;
            _complete = false; 
            
            // check our 'success' conditions are maintained
            while {(_bomb distance _engineer < 5) && (alive _engineer)} do {
             	if (time > _endTime) exitWith { [west, "HQ"] sideChat "complete"; _complete = true };
            	sleep 1;
            };
            
            // check if we succeeded and react
            if (_complete) then {
                [west, "HQ"] sideChat "yes";
            } else {
                [west, "HQ"] sideChat "no";
            };
            sigpic

            Comment


            • #7
              Re: Action with a progress bar

              May I use your example in the future?

              Current ARMA Development Project: No Current Project

              "An infantryman needs a leader to be the standard against which he can judge all soldiers."

              Friend of |TG| Chief

              Comment


              • #8
                Re: Action with a progress bar

                Sure :)
                sigpic

                Comment


                • #9
                  Re: Action with a progress bar

                  Just in case you still wanted to refer to that original thread with the messed up formatting, I have converted it for you to make it easier digest.

                  FYI, for old posts like that with old HTML formatting, you can go to a converter site like Web 2.0 Generators Entity Converter and "Decode" it to make it plain text. You might also have to hit return after semi-colons or use an editor's replace function to replace semi-colons with a semi colon and a line break to get the right spacing but other than it is much easier to read after conversion. Here is the code:


                  Code:
                  if (player distance (_this select 0) > 1) exitWith {player sidechat "I have to get closer..."};
                   if (defusing) exitWith {player sidechat "Im already defusing..."};
                   defusing = true;
                   player playMove "ainvpknlmstpslaywrfldnon";
                   waitUntil {(animationState player == "ainvpknlmstpslaywrfldnon") or !alive player};
                   defuseInfoT = "
                  
                  Defusing bomb...
                  [====================]";
                   _i = 0;
                   _j = 0;
                   while {(_i<20) and (alive player)} do { sleep 0.5;
                   defuseInfoT = "
                  
                  Defusing bomb...
                  ";
                   defuseInfoT = defuseInfoT+"[";
                   while {_j <= _i} do { defuseInfoT = defuseInfoT+"=";
                   _j = _j + 1;
                   };
                   _j = 0;
                   while {_j + _i < 19} do { defuseInfoT = defuseInfoT + "=";
                   _j = _j + 1;
                   };
                   defuseInfoT = defuseInfoT + "]";
                   _i = _i + 1;
                   _j = 0;
                   if (!alive player) exitWith {defusing=false};
                   if (animationState player != "ainvpknlmstpslaywrfldnon") exitWith {player sidechat "Defuse aborted";
                  defusing = false};
                   };
                   defuseInfoT = "
                  
                  Done!
                  [====================]";
                   sleep 2;
                   defuseInfoT = "";
                  LoyalGuard

                  Comment


                  • #10
                    Re: Action with a progress bar

                    Hi loyalguard, yeah I'm familiar with HTML entities but was too lazy I guess :) The solution looks slightly more rudimentry but gives a bit more flexibility around where the "progress bar" goes. I'll stick with the ACE solution for now as it seems a bit neater.

                    Thanks!
                    sigpic

                    Comment


                    • #11
                      Re: Action with a progress bar

                      Thanks Loyalguard.

                      Current ARMA Development Project: No Current Project

                      "An infantryman needs a leader to be the standard against which he can judge all soldiers."

                      Friend of |TG| Chief

                      Comment

                      Connect

                      Collapse

                      TeamSpeak 3 Server

                      Collapse

                      Advertisement

                      Collapse

                      Twitter Feed

                      Collapse

                      Working...
                      X