Search the Community
Showing results for tags 'compact'.
Found 3 results
-
Removing whitespace script release
das attorney posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Preamble: From the wiki, we can use splitstring and joinstring to remove white space from code. So if we have a function like this one (from the wiki): fnc_deleteTestObj = { _this addMPEventHandler ["MPKilled", { _this = _this select 0; { deleteVehicle _x; } forEach (_this getVariable ["effects", []]); if (isServer) then { deleteVehicle _this; }; }]; _this setDamage 1; }; We can do: copyToClipboard(([fnc_deleteTestObj] joinString "") splitString toString [9,13,10] joinString "") and it returns: { _this addMPEventHandler ["MPKilled", { _this = _this select 0; { deleteVehicle _x; } forEach (_this getVariable ["effects", []]); if (isServer) then { deleteVehicle _this; }; }]; _this setDamage 1; } Which is quite nice. But I wanted a way to remove as much white space as I can (for sending code/variables over the network etc), plus I just fancied playing about with recursion. So with this function, we can use our "fnc_deleteTestObj" function again and plug it in: copyToClipboard(([fnc_deleteTestObj] joinString "") call fnc_whitespace) This returns: {_this addMPEventHandler["MPKilled",{_this=_this select 0;{deleteVehicle _x;}forEach(_this getVariable["effects",[]]);if(isServer)then{deleteVehicle _this;};}];_this setDamage 1;} I'm using joinstring in these examples as opposed to format as it doesn't have the 8k limit. Apparently formatText isn't limited and I'm not sure about str. But you could do this I suppose - just be aware it might have a limit: (str fnc_deleteTestObj) call fnc_whitespace Uses As mentioned, you could shorten variables prior to sending them over the network (then compileFinal at other end). I'm aware that programs like these exist already, but I wanted to do it in sqf (like within the engine). It should be ok but will have a problem if you do silly things like putting spaces into variables ex: player setVariable ["there are spaces in this",true]; which is a bit of a no-no imo and bad practice. You could probably obfuscate your code with this if you want but there are already good online obfuscators available anyway, and also good online de-obfuscators, like this one: http://unminify.com/ I think Dwarden said he used to do this to his mission files to make them smaller so they wouldn't suck up as much bandwidth, so theres a use for it there I suppose. Obv, I haven't tested this much but it seems ok so far - ymmv. Be aware if you use it on very large functions, then it is recursive so it might freeze your game for a few seconds. If you rename it, make sure you rename the call to it in the code as well or you will break it. Function: Here it is for any interested: fnc_whitespace = { private _noWhitespace = toArray(_this); private _anyWS = false; { if (0 isEqualType _x) then { if ([9,13,10] find _x > -1) then { _noWhitespace set [_forEachIndex,objNull]; _anyWS = true; } else { if ([34,39,94,42,40,41,123,125,91,93,59,58,62,47,43,45,61,46] find _x > -1) then { if (_forEachIndex - 1 > -1) then { if ([32,9,13,10] find (_noWhitespace select (_forEachIndex - 1)) > -1) then { _noWhitespace set [_forEachIndex - 1,objNull]; _anyWS = true; } }; if (_forEachIndex + 1 < count _noWhitespace) then { if ([32,9,13,10] find (_noWhitespace select (_forEachIndex + 1)) > -1) then { _noWhitespace set [_forEachIndex + 1,objNull]; _anyWS = true; } }; } } }; } forEach _noWhitespace; _noWhitespace = _noWhitespace - [objNull]; if (_anyWS) then { _noWhitespace = (toString _noWhitespace) call fnc_whitespace; _noWhitespace = toArray _noWhitespace; }; toString(_noWhitespace) }; And here it is compacted (ho ho ho): fnc_whitespace={private _noWhitespace=toArray(_this);private _anyWS=false;{if(0 isEqualType _x)then{if([9,13,10]find _x>-1)then{_noWhitespace set[_forEachIndex,objNull];_anyWS=true;}else{if([34,39,94,42,40,41,123,125,91,93,59,58,62,47,43,45,61,46]find _x>-1)then{if(_forEachIndex-1>-1)then{if([32,9,13,10]find(_noWhitespace select(_forEachIndex-1))>-1)then{_noWhitespace set[_forEachIndex-1,objNull];_anyWS=true;}};if(_forEachIndex+1 < count _noWhitespace)then{if([32,9,13,10]find(_noWhitespace select(_forEachIndex+1))>-1)then{_noWhitespace set[_forEachIndex+1,objNull];_anyWS=true;}};}}};}forEach _noWhitespace;_noWhitespace=_noWhitespace-[objNull];if(_anyWS)then{_noWhitespace=(toString _noWhitespace)call fnc_whitespace;_noWhitespace=toArray _noWhitespace;};toString(_noWhitespace)} Credit to @dreadedentity for his initial code HERE Enjoy!- 11 replies
-
- 6
-
- remove
- whitespace
-
(and 5 more)
Tagged with:
-
So right now I am working on a mod to add my clans insignia. I want to do this vs using the description.ext method for many reasons. Anyways, When I use the description.ext method, the emblem loads in just fine. But if I use the mod method, they don't seem to load right. I go to the virtual ammobox and the emblems are listed, but the preview icon isnt there, and it doesn't show up on the uniform. So I am not sure if I am doing something wrong with my config.cpp because when I do it via the description.ext, its fine. Here is my config class CfgPatches { class UNS_Patches { units[] = {}; weapons[] = {}; requiredVersion = 0.1; requiredAddons[] = {"A3_Characters_F_BLUFOR"}; version = 1.0; author[] = {"Kocrachon"}; }; }; class CfgMods { class ISA_Patches { dir = "ISA_Patches"; name = "ISA Patch and Insignia"; picture = "/ISA_Patches/sqd_logo.paa"; hidePicture = "false"; hideName = "false"; action = "http://www.isa-clan.com"; }; }; class CfgUnitInsignia { class PATCH_ISA_MAIN { displayName = "ISA Insignia"; author = "Kocrachon"; texture = "ISA_Patches\data\isa\sqd_logo.paa"; textureVehicle = ""; }; class PATCH_ISA_EMBLEM { displayName = "ISA Emblem"; author = "Kocrachon"; texture = "ISA_Patches\data\isa\squad_emblem.paa"; textureVehicle = ""; }; };
-
http://lockheedmartin.com/us/products/compact-fusion.html so let's discuss this promising technology, 10-100MW on truck, ship, building ... this will change heavy military in nutshell note: there is also ongoing discussion in LENR thread http://forums.bistudio.com/showthread.php?139458-LENR-quot-Cold-Fusion-quot-Pons-and-Fleischman-got-it-right-sort-of-say-NASA-MIT-Stanford-etc