Jump to content
x39

unexpected script runtime issue when putting much code into variables by a seperated

Recommended Posts

... call (not sure if thats the source of the issue)






Required info for this


required info:

my steamaccount for direct chat if required

Problem


Due my modding project XMS2 i discovered that arma somehow bugs some code out so that it is not possible to execute it without runtime issues

(check the code below)

#include "\X39_MS2_Scripting\default.hpp"
/*
*    THIS FUNCTION IS NOT INTENDED TO BE CALLEN BY ANY USERSCRIPT!
*
*    ArrayStructure:
*        0+ STRING        - displayed text
*        1+ STRING        - limitation name
*        2+ BOOL            - allow usage inside of a vehicle
*        3+ CODE            - condition to display option
*        4+ STRING/CODE    - code to execute when action is performed
*    
*    @Return - N/A
*    @Author - X39|Cpt. HM Murdock
*/
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_openMedicalMenu",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       [X39_XLib_var_ActionDialog_Executor] call X39_MS2_fnc_MedicalActionMenu_createDialog;
   },
   {X39_XLib_var_ActionDialog_IsSelf}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_openMedicalMenu",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       if(isNull X39_XLib_var_ActionDialog_Target) exitWith {false};
       [X39_XLib_var_ActionDialog_Target] call X39_MS2_fnc_MedicalActionMenu_createDialog;
   },
   {!X39_XLib_var_ActionDialog_IsSelf}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_putEarplugs",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       X39_XLib_var_ActionDialog_Target setVariable ["X39_MS2_var_hasEarplugs", true];
       X39_XLib_var_ActionDialog_Target removeItem "x39_xms2_earplugs";
   },
   {((items X39_XLib_var_ActionDialog_Target) find "x39_xms2_earplugs" != -1) && !(X39_XLib_var_ActionDialog_Target getVariable ["X39_MS2_var_hasEarplugs", false])}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_removeEarplugs",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       X39_XLib_var_ActionDialog_Target setVariable ["X39_MS2_var_hasEarplugs", false];
       X39_XLib_var_ActionDialog_Target addItem "x39_xms2_earplugs";
   },
   {(X39_XLib_var_ActionDialog_Target getVariable ["X39_MS2_var_hasEarplugs", false])}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_putTourniquet",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       X39_XLib_var_ActionDialog_Target setVariable ["X39_MS2_var_hasTourniquet", true];
       if("x39_xms2_tourniquet" in (items X39_XLib_var_ActionDialog_Target)) then
       {
           X39_XLib_var_ActionDialog_Target removeItem "x39_xms2_tourniquet";
       }
       else
       {
           X39_XLib_var_ActionDialog_Executor removeItem "x39_xms2_tourniquet";
       };
   },
   {(((items X39_XLib_var_ActionDialog_Executor) find "x39_xms2_tourniquet" != -1) || ((items X39_XLib_var_ActionDialog_Target) find "x39_xms2_tourniquet" != -1)) && !(X39_XLib_var_ActionDialog_Target getVariable ["X39_MS2_var_hasTourniquet", false])}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_removeTourniquet",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       X39_XLib_var_ActionDialog_Target setVariable ["X39_MS2_var_hasTourniquet", false];
       X39_XLib_var_ActionDialog_Executor addItem "x39_xms2_tourniquet";
   },
   {(X39_XLib_var_ActionDialog_Target getVariable ["X39_MS2_var_hasTourniquet", false])}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_useDefibrillator",
   "",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       [X39_XLib_var_ActionDialog_Executor, X39_XLib_var_ActionDialog_Target] spawn X39_MS2_fnc_MA_defibrillate;
   },
   {
       !X39_XLib_var_ActionDialog_IsSelf && !X39_XLib_var_ActionDialog_ExecutorInVehicle &&
       {
           (((items X39_XLib_var_ActionDialog_Target) find "x39_xms2_defibrillator") != -1) ||
           {
               (((items X39_XLib_var_ActionDialog_Executor) find "x39_xms2_defibrillator") != -1) &&
               {
                   ([X39_XLib_var_ActionDialog_Target] call X39_MS2_fnc_getBlackOutStage) >= 3
               }
           }
       }
   }
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_stripWeapons",
   "",
   {
       private["_gearHolder", "_x"];
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       _gearHolder = "GroundWeaponHolder" createVehicle position X39_XLib_var_ActionDialog_Executor;
       {
           _gearHolder addWeaponCargoGlobal[_x, 1];
           X39_XLib_var_ActionDialog_Target removeWeapon _x;
       }foreach (weapons X39_XLib_var_ActionDialog_Target);
   },
   {!X39_XLib_var_ActionDialog_IsSelf && !X39_XLib_var_ActionDialog_ExecutorInVehicle}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_dragUnit",
   "",
   {

       _animation = "";
       if(primaryWeapon X39_XLib_var_ActionDialog_Executor == "" && secondaryWeapon X39_XLib_var_ActionDialog_Executor == "") then
       {
           _animation = "AcinPknlMstpSnonWnonDnon";
       }
       else
       {
           if(primaryWeapon X39_XLib_var_ActionDialog_Executor == "") then
           {
               _animation = "AcinPknlMstpSnonWpstDnon";
           }
           else
           {
               _animation = "AcinPknlMstpSrasWrflDnon";
           };
       };
       X39_XLib_var_ActionDialog_Executor playMove _animation;

       X39_XLib_var_ActionDialog_Target attachTo [X39_XLib_var_ActionDialog_Executor, [0, 1.1, 0]];
       X39_XLib_var_ActionDialog_Target setDir 180;
       X39_XLib_var_ActionDialog_Target switchMove "AinjPpneMstpSnonWrflDb"; 
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
   },
   {!X39_XLib_var_ActionDialog_IsSelf && !X39_XLib_var_ActionDialog_ExecutorInVehicle && {({(_x getVariable ["X39_MS2_var_UnitInitialized", false])} count attachedObjects X39_XLib_var_ActionDialog_Executor) <= 0}}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   localize "STR_X39_MS2_Scripting_InteractionMenu_dropUnit",
   "",
   {
       private["_unit", "_x"];
       X39_XLib_var_ActionDialog_Executor playMove "AidlPknlMstpSrasWrflDnon_AI"; 
       _unit = objNull;
       {
           if(_x getVariable ["X39_MS2_var_UnitInitialized", false]) then
           {
               _unit = _x;
           };
           false
       } count attachedObjects X39_XLib_var_ActionDialog_Executor;
       if(!isNull _unit) then
       {
           detach _unit;
           _unit playMove "AinjPpneMstpSnonWrflDb_release";
       }
       else
       {
           systemChat "WHOOOPS! Something moved TERRIBLY wrong ...";
           systemChat "Seems like ArmA bugs out with SQF AGAIN -.-*";
           systemChat "Please report at XMS2 bugTracker and well ...";
           systemChat "keep attached : /";
       };
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
   },
   {X39_XLib_var_ActionDialog_IsSelf && !X39_XLib_var_ActionDialog_ExecutorInVehicle && {({(_x getVariable ["X39_MS2_var_UnitInitialized", false])} count attachedObjects X39_XLib_var_ActionDialog_Executor) > 0}}
] call X39_XLib_fnc_ActionDialog_registerAction;
[
   "Add 2000 blood to body",
   {
       [] call X39_XLib_fnc_ActionDialog_closeDialog;
       [X39_XLib_var_ActionDialog_Target, 2000] call X39_MS2_fnc_addBlood;
       systemChat "THIS IS A DUMMY IMPLEMENTATION! So please dont expect something will happen now ... ^^";
       systemChat "((for sure ... the target now has 2000 blood added))";
   },
   {!X39_XLib_var_ActionDialog_IsSelf && !X39_XLib_var_ActionDialog_ExecutorInVehicle}
] call X39_XLib_fnc_ActionDialog_registerAction;

there is no issue inside of this peice of code

but arma thinks different:

Error in expression <else>Error position: <else>
Error Undefined variable in expression: else
Error in expression <else>
Error position: <else>
Error Undefined variable in expression: else

(sometimes arma also prints that the operation _unit = _x would be invalid ...)

this only happens if that piece of code is callen in a function (in the ESC debug menu it works fine)

Any ideas?

Edited by X39

Share this post


Link to post
Share on other sites

BTW animation ""AinjPpneMstpSnonWrflDb"" in Arma 3 used for drag wounded or dead bodies attached via attachto command not working well - body is in ragdoll state and isn't conecting to carry unit,  only after detach body is moving to drop position instatntly.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×