-
Content Count
43 -
Joined
-
Last visited
-
Medals
Everything posted by PixeL_GaMMa
-
As the title implies, I decided to put together a tool for me and my friends. I have many plans for improvements. But for now it is a basic and simple tool that gets the job done. It is designed to be simple and quick to use without any over complexity. A couple of screenshots: I want to share it with the community and will happily note any suggestions and requests. If you're interested in trying out a new tool, you can get it from https://colinstewart.pw/project/anl-13. Please bare in mind that this is the first initial version. It can be run from any directory, it does not have to placed inside of your Arma 3 installation directory. -Colin
-
Back again with another function, Not sure if there are other string replacement routines, but I've quickly put this one together. Source // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private _return = ""; private _len = count _find; private _pos = _str find _find; while {(_pos != -1) && (count _str > 0)} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _find; }; _return + _str; }; Example: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplace; // Output: Arma is awesome, I love Arma! -Colin
-
[SOLVED] callExtension - Insufficient system resources
PixeL_GaMMa replied to HazJ's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Can you show the sql statement you are passing? Or is this from first initialization of the library? Have you also placed the libmariadb files into Arma 3 directory? (required by the addon initialization process) -
BIS_fnc_spawnGroup + playable
PixeL_GaMMa replied to JVez's topic in ARMA 3 - MISSION EDITING & SCRIPTING
BIS_fnc_spawnGroup returns a group ..... _grp = ...... call BIS_fnc_spawnGroup ; { .... } forEach (units _grp); -
Hi there, is it possible to grab the current vehicle seed of a randomized vehicle and load up that vehicle again? e.g. If i create a pickup truck and it randomizes it without 1 of the doors, is it possible to grab the state of that vehicle and re-load it at a later time? I already have persistence for vehicles, but it only stores damage level and class of the vehicle, but I would also like to store the current state/randomized version of that vehicle. -Colin
-
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
After a short break away from screen, another look and I see my mistake, I forgot to add additional select 0 to all hit points array. { _veh setHitPointDamage [_x, (_hitPoints select _forEachIndex)]; } forEach ((getAllHitPointsDamage _veh) select 0) select 0; In-fact a better way would be { _veh setHitIndex [_forEachIndex, _x, false]; } forEach (_this select 5); Now it looks like damage is working, but a tire that is blown is back when re-loaded, I would have assumed the animation would correct this but it still does not work. :/ getting into the vehicle shows the wheels are damaged, but the physical model/animation for damage is not updated. OK, a bit re-ordering, and it seems to be working: // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir (_this select 2); _veh setFuel (_this select 3); _veh setMass (_this select 4); private _textures = (_this select 6); private _phaseData = (_this select 7); { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); { _veh setHitIndex [_forEachIndex, _x, false]; } forEach (_this select 5); _veh; }; -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yes, it is executed directly on server as it is created (see function above) -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've just updated my game mode to use the new functions, but it seems setHitPointDamage doesn't work globally, any idea what the problem could be? -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Excellent idea, we could also add per hit point damage // // PX_fnc_getVehicleState :: Get vehicles current state - Note: this does not save inventory // Author: Colin J.D. Stewart // Usage: _stateblock = _vehicle call PX_fnc_getVehicleState; // PX_fnc_getVehicleState = { [ typeOf _this, getPosATL _this, getDir _this, fuel _this, getMass _this, (getAllHitPointsDamage _this) select 2, getObjectTextures _this, animationnames _this apply {_this animationPhase _x} // thanks Grumpy Old Man here for help ]; }; // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir (_this select 2); _veh setFuel (_this select 3); _veh setMass (_this select 4); private _hitPoints = (_this select 5); { _veh setHitPointDamage [_x, _hitPoints select _forEachIndex]; } forEach (getAllHitPointsDamage _veh) select 0; private _textures = (_this select 6); private _phaseData = (_this select 7); { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); _veh; }; -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
OK just put these together, not tested since my game mode doesn't use them directly like this, but they should work Source // // PX_fnc_getVehicleState :: Get vehicles current state - Note: this does not save inventory // Author: Colin J.D. Stewart // Usage: _stateblock = _vehicle call PX_fnc_getVehicleState; // PX_fnc_getVehicleState = { [ typeOf _this, getPosATL _this, getDir _this, fuel _this, getMass _this, damage _this, getObjectTextures _this, animationnames _this apply {_this animationPhase _x} // thanks Grumpy Old Man here for help ]; }; // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir _this select 2; _veh setFuel _this select 3; _veh setMass _this select 4; _veh setDamage _this select 5; private _textures = _this select 6; private _phaseData = _this select 7; { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); _veh; }; There are probably many improvements could be made here, but it's a start :) Best Regards, Colin -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yep, but when the vehicle is saved (persistently) I can just do a getMass _veh; save this and when the vehicle is loaded, apply the animation data and then setMass ... etc Edit: Implemented and tested, along with getObjectTextures, it all works perfectly, thanks again for help, I will post the functions soon :) -
vehicle randomization data
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yep, ideally it would be a single seed for a vehicle, how i do it in some of my procedural projects is have a seed that can be re-used. When the vehicle is generated, it is generated using a specific random seed/number, then if that seed is used again it would be generated in the exact same way, in which case it would be as simple as saving a single number and re-using it when calling createVehicle, that would have been perfect. Your code actually may be ideal, I can also just store a total of the mass rather than iterate the missing pieces. I assume the centre of mass also changes depending on this? Thanks for your help :) p.s. I already wrote a setCargoLoadout and getCargoLoadout which is ideal for vehicles and cargo boxes, I will release it once I make some improvements probably. :) -
Event handler ContainerClosed server side?
PixeL_GaMMa posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
_this addEventHandler ["ContainerClosed", { .... etc As the title.... is it possible to get this event to fire server side? or will it only fire on the client? -
Event handler ContainerClosed server side?
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yep I'm thinking about using InventoryClosed which can then remote call server side function (assuming, it is the correct type of container) ... probably this will be fine. Thanks again. -
Event handler ContainerClosed server side?
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
The problem with this is containers are dynamic and can be 100s, so to add event handler to all containers on all clients would be too much, I will try to come up with an alternative method. Thanks for help. -
Event handler ContainerClosed server side?
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
ok thanks will do some tests. -
Event handler ContainerClosed server side?
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Will this still work if the event is assigned from the server? (wiki says it is global) -
Event handler ContainerClosed server side?
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I want to fire a server only function when a container is closed (specifically in this case a vehicle), without relying/trusting the client to call the function remotely.... -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
yep, check third param of BIS_fnc_splitString -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Awesome, thanks, I think it is good enough.... I did experiment with split string and join, it can be done but it does not perform very well. But i will add it here anyway. PX_fnc_splitReplace = { params["_str", "_find", "_replace"]; private _result = ([" "+_str+" ", _find, true] call BIS_fnc_splitString) joinString _replace; _result select [1, (count _result)-2]; }; The reason for the spaces is because bis splitstring will remove the found words if they are at the start or end of the string. -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yep, I considered writing a plugin in Ziron (assembly), but the main issue being that this could only be used server-side, unless users are willing to install a client side plugin (most people, especially new-comers are oblivious how to do that) -so the only alternative is to write optimised sqf :) -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Grumpy Old Man: Loops will always be better than recursive calls in the long run, and your function does not replace multiple keys :P MuzzleFlash: I would be interested to see these added to your variation of tests :) // // PX_fnc_stringReplaceEx :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplaceEx; // PX_fnc_stringReplaceEx = { params["_str", "_find", "_replace"]; private _pos = _str find _find; if (_pos == -1) exitWith {_str}; private _return = ""; private _len = count _find; while {_pos != -1} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _find; }; _return + _str; }; // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx" || [], "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private["_return", "_len", "_pos"]; if (!(_find isEqualType [])) then { _find = [_find]; }; { _pos = _str find _x; if (_pos != -1) then { _return = ""; _len = count _x; while {_pos != -1} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _x; }; _str = _return + _str; }; } forEach _find; _str; }; -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
another could be multi-line listbox tooltips, replacing <br /> to \n for it to work :) _hint = [getText(configFile >> "CfgMagazines" >> _class >> "descriptionShort"), ["<br />", "<br/>"], "\n"] call PX_fnc_stringReplace; > -
quick stringReplace
PixeL_GaMMa replied to PixeL_GaMMa's topic in ARMA 3 - MISSION EDITING & SCRIPTING
A quick update that I required today for replacing multiple strings with value: // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx" || [], "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private["_return", "_len", "_pos"]; if (!(_find isEqualType [])) then { _find = [_find]; }; { _return = ""; _len = count _x; _pos = _str find _x; while {(_pos != -1) && (count _str > 0)} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _x; }; _str = _return + _str; } forEach _find; _str; }; This will allow: ["abc<br>def<br />ghi<br/>jkl!", ["<br>", "<br/>", "<br />"], "\n"] call PX_fnc_stringReplace; In the scenario above, there are better ways to accomplish this, but this is the lazy and easy way :) -
lnbSetTooltip multi-column tooltip
PixeL_GaMMa posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
So I noticed there was no lnbSetTooltip and upon using lbSetTooltip it seems it takes columns into consideration too, this can be quite confusing at times and easy to forget. If anyone else has this problem, I've made a tiny function to relieve the stress and add the missing lnbSetTooltip // // API missing function lnbSetTooltip for usage with ListNBox // Author: Colin J.D. Stewart. // usage: [ctrl, index, colcount, "text"] call lnbSetTooltip; // lnbSetTooltip = { params["_ctrl", "_index", "_cols", "_text"]; _ctrl lbSetTooltip [_index + ((_cols-1)*_index), _text]; }; Params: _ctrl = the ListNBox control _index = the index of the row via addRow _cols = how many columns your listnBox has declared. _text = the obvious, the text you want for the tooltip [_row, 5, 3, "My tooltip"] call lnbSetTooltip; Result: You could optimise this by changing this into a preprocessed macro instead. Or maybe I am missing something? I was unable to find any other lnb functions though. -Colin