Jump to content
ROTAHOE

Need new string output

Recommended Posts

This is not my code but needing the string output to be as mentioned below.

Any help would be amazing !

 

Cheers

 

Code to function:

initiated = false;
posdistance = 10;
posrotation = true;
Objlist = [];
lootPosition = [0,0,0];
dump = [];
buildingcategory = "";
poslist = [];
surdistance = 0.1;
 
if (!isNil "started") exitWith {};
started = true;
waitUntil {!isNull (findDisplay 46);};
 
(findDisplay 46) displayAddEventHandler ['KeyUp','_this call keybinder'];
 
//TP function
["teleportSelf","onMapSingleClick",{vehicle player setPos [_pos select 0, _pos select 1,0];}] call BIS_fnc_addStackedEventHandler;
 
//Add line to file
dumpline =
{
    dump = dump + [[_this,tostring[13]]Joinstring ""];
};
 
//Create file header
catList =
[
    "Civillian",
    "Commercial",
    "Mechanical",
    "Industrial",
    "Medical",
    "Military"
];
_line = "";
 
_line = [tostring[47,47],"Loot positions created with @Lootpos by SLIdeCLAN"]Joinstring "";
_line call dumpline;
{
    _line =
    [
        tostring[13,9],"class ",_x," {",
        tostring[13,9,9],"table = ",tostring[34],_x,tostring[34],";",
        tostring[13,9],"};"
    ]Joinstring "";
    _line call dumpline;       
}foreach catList;
 
popupclose = {
    _combobox = (findDisplay 983475) displayCtrl 2100;
    _sel = lbCurSel _combobox;
    buildingcategory = _combobox lbText _sel;
    _line = [tostring[9],"class ",buildingClass,": ",buildingcategory,tostring[13],tostring[9],"{"]joinstring "";
    _line call dumpline;
    systemChat Format["LootPos initiated on %1: %2",buildingClass,buildingcategory];
    initiated = true;
};
 
//Visual Ball
Ball = createVehicle ["Sign_Sphere25cm_F",[0,0,0],[],0,"CAN_COLLIDE"];
 
[   "visualeffect",
    "onEachFrame",
    {
        _intersection = lineIntersectsSurfaces [AGLToASL positionCameraToWorld [0,0,0],AGLToASL positionCameraToWorld [0,0,posdistance] ,player,objNull,true,1,"GEOM","NONE"];
        if (count(_intersection) == 0) then
        {
            lootPosition = ASLtoATL(AGLToASL positionCameraToWorld [0,0,posdistance]);
            buildingtemp = ObjNull;
            buildingClasstemp = "";
        }
        else
        {
            lootPosition = ASLtoATL(_intersection select 0 select 0);
            _vector = (_intersection select 0 select 1);
            lootPosition = lootPosition vectorAdd (_vector vectormultiply surdistance);
            buildingtemp = _intersection select 0 select 2;
            buildingClasstemp = typeOf buildingtemp;
        };
       
        Ball setpos lootPosition;
        hint format["%1",buildingClasstemp];
    }
] call BIS_fnc_addStackedEventHandler;
 
completeEntry = {
    _formatedDump = [([tostring[9,9],"positions[] =",tostring[13,9,9],"{",tostring[13]]joinstring "")];
    _last = (count poslist)-1;
    {
        if (_foreachindex == _last) then
        {
            _formatedDump = _formatedDump + [([tostring[9,9,9],"{",_x select 0,tostring[44], _x select 1,tostring[44], _x select 2,"}",tostring[13]]joinstring "")];
        }
        else
        {
            _formatedDump = _formatedDump + [([tostring[9,9,9],"{",_x select 0,tostring[44], _x select 1,tostring[44], _x select 2,"}",tostring[44],tostring[13]]joinstring "")];
        };
    }forEach poslist;
   
    _formatedDump = _formatedDump + [([tostring[9,9],"};",tostring[13,9],"};",tostring[13]]joinstring "")];
    _line = (_formatedDump joinstring "");
    _line call dumpline;
    poslist = [];
    building = ObjNull;
    buildingClass = "";
    {
        deleteVehicle _x;
    }foreach Objlist;
    Objlist = [];
    initiated = false;
};
 
createFile = {
 
    _dumpstring = dump joinstring "";
    copyToClipboard _dumpstring;
    "make_file" callExtension ("lootpositions.hpp" + "|" + _dumpstring);
    systemChat "Data copied to clipboard and file create if make_file.dll was present and lootpositions.hpp not already created";
 
};
 
keybinder = {
    //9 Instructions
    if ((_this select 1) == 0x0A) then {
        systemChat "Make sure you have debug_console.dll in your Arma 3 directory";
        systemChat "1. Point a building and press 1 to initiate lootpos creation";
        systemChat "2. Move around the building and press 2 to create a position at the position you are pointing at.";
        systemChat "3. Press 3 to auto-generate current building";
        systemChat "4. Press 4 to complete the building loot position definition";
        systemChat "5. Press 5 to create file with make_file.dll and to copy to clipboard";
        systemChat "7. Press 7 to auto-generate the full map";
        systemChat "- Press Page Up to push the position";
        systemChat "- Press Page Down to pull the position";
        systemChat "- Press Home to increase the surface distance";
        systemChat "- Press End to decrease the surface distance";
    };
    //1 Init
    if ((_this select 1) == 0x02) then {
        if (initiated) then
        {
            systemChat Format["Already initiated on %1",buildingClass];
        }
        else
        {
            if (buildingClasstemp == "") then
            {
                systemChat "No building captured";
            }
            else
            {
                buildingcategory = "";
                building = buildingtemp;
                buildingClass = buildingClasstemp;
                _ok = createDialog "popup";
                _combobox = (findDisplay 983475) displayCtrl 2100;
                {_combobox lbAdd _x} forEach catList;
            };
        }; 
    };
   
 
    //2 Place loot position on target
    if ((_this select 1) == 0x03) then
    {
        if (initiated) then
        {
            _spotObj = createVehicle ["Sign_Sphere25cm_F",lootPosition,[],0,"CAN_COLLIDE"];
            Objlist = Objlist + [_spotObj];
            _spotPos = building worldToModel (getPosATL _spotObj);
            poslist = poslist + [_spotPos];
            systemChat Format["Position Created at %1",_spotPos];
        }
        else
        {
            systemChat "Not initiated, use 1 on a building to initiate";
        };
    };
   
    //3 Autogenerate current
   
    if ((_this select 1) == 0x04) then
    {
        if (initiated) then
        {
            _positions = [];
            _positions = building call BIS_fnc_buildingPositions;
            {
                _spotObj = createVehicle ["Sign_Sphere25cm_F",_x,[],0,"CAN_COLLIDE"];
                Objlist = Objlist + [_spotObj];
                _spotPos = building worldToModel _x;
                poslist = poslist + [_spotPos];
                systemChat Format["Position Created at %1",_spotPos];
            }foreach _positions;
            systemChat Format[" %1 Positions Created at",count _positions];
        }
        else
        {
            systemChat "Not initiated, use 1 on a building to initiate";
        };
    };
   
    //4 Complete
    if ((_this select 1) == 0x05) then {
        if (initiated) then
        {
            call completeEntry;
            systemChat "class Creation completed";
        };
    };
   
    //5 make file
    if ((_this select 1) == 0x06) then {
        if (initiated) then
        {
            systemChat "Press 3 to complete class before exporting file";
        }
        else
        {
            call createFile;
        };
    };
   
    //7 auto-generate full map
    if ((_this select 1) == 0x08) then
    {
        if (initiated) then
        {
            systemChat "DO NOT INITIATE BEFORE GENERATING FULL MAP";
        }
        else
        {
            //Create array with all buildings
            _allBuildings = [];
            _allBuildings = [12000,12000] nearObjects ["House",12000];
            //array of all valid buidling classes
            _allBuildingClasses = [];
            {
                _buildingClass = (typeof _x);
                _buildingObj = _x;
                if (((_allBuildingClasses find _buildingClass) < 0) and (count(_x call BIS_fnc_buildingPositions) > 0)) then
                {
                    _allBuildingClasses = _allBuildingClasses + [(typeof _x)]; 
 
                    _positions = [];
                    _positions = _buildingObj call BIS_fnc_buildingPositions;
                    {
                        _spotObj = createVehicle ["Sign_Sphere25cm_F",_x,[],0,"CAN_COLLIDE"];
                        Objlist = Objlist + [_spotObj];
                        _spotPos = _buildingObj worldToModel _x;
                        poslist = poslist + [_spotPos];
                    }foreach _positions;
                   
                    _line = [tostring[9],"class ",_buildingClass,": ","ReplaceMe",tostring[13],tostring[9],"{"]joinstring "";
                    _line call dumpline;
                    call completeEntry;
                };
            }foreach _allBuildings;
            call createFile;
            systemChat Format[" %1 Building Generated",count _allBuildingClasses];
        };
    };
   
    //pull PGDN
    if ((_this select 1) == 0xD1) then
    {
        posdistance = posdistance - 1;
        systemChat format["Loot position distance = %1",posdistance];
    };
    //push PGUP
    if ((_this select 1) == 0xC9) then
    {
        posdistance = posdistance + 1;
        systemChat format["Loot position distance = %1",posdistance];
    };
    //increase distance to surface HOME
    if ((_this select 1) == 0xC7) then
    {
        surdistance = surdistance + 0.1;
        systemChat format["Loot position distance to surface = %1",surdistance];
    };
    //decrease distance to surface END
    if ((_this select 1) == 0xCF) then
    {
        surdistance = surdistance - 0.1;
        systemChat format["Loot position distance to surface = %1",surdistance];
    }; 
};

original output:

lass Land_sz_Tent_East: Military
    {
        positions[] =
        {
            {2.90234,-2.14453,-1.65378},
            {2.33789,1.27441,-1.65509},
            {0.192383,0.954102,-1.65564},
            {-2.89746,1.77637,-1.65616},
            {-2.23291,-1.2002,-1.65613},
            {-3.39648,-1.97852,-1.65533},
            {-3.20898,-0.0351563,-1.6561},
            {1.50439,-0.712891,-1.65558}
        };
    };

Needed output:

class Land_sz_Tent_East {
        table = "Military";
        positions[] =
        {
            {2.90234,-2.14453,-1.65378},
            {2.33789,1.27441,-1.65509},
            {0.192383,0.954102,-1.65564},
            {-2.89746,1.77637,-1.65616},
            {-2.23291,-1.2002,-1.65613},
            {-3.39648,-1.97852,-1.65533},
            {-3.20898,-0.0351563,-1.6561},
            {1.50439,-0.712891,-1.65558}
        };
    };

 

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

×