-
Content Count
335 -
Joined
-
Last visited
-
Medals
-
serena changed their profile photo
-
Modifying function location issues
serena replied to anfo's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I use such rather flexible and convenient approach: // Abc.sqf Abc_FuncX = {...}; Abc_FuncY = {...}; Abc_FuncZ = {...}; // Def.sqf Def_FuncX = {...}; Def_FuncY = {...}; Def_FuncZ = {...}; // init.sqf call compile preprocessFileLineNumbers "Abc.sqf"; call compile preprocessFileLineNumbers "Def.sqf"; // Somewhere in mission: ... call Abc_FuncX; ... call Def_FuncZ; -
Coding shortcut - Very large array with same naming convention
serena replied to TheGeneral2899's topic in ARMA 3 - MISSION EDITING & SCRIPTING
It looks cool, but ... Allocate in memory an array with a removed element -> compare elements of two arrays -> allocate new array to storing result -> partially copy elements of source array into resulting. Isn't too expensive? -
How To Get Location Names To Show Up On Screen
serena replied to Cerbium's topic in ARMA 3 - MISSION EDITING & SCRIPTING
My code above does not solve your problem completely, only demonstrates how to get names and other useful attributes of locations. -
random spawn Marker randomly spawned at one of several predetermined possitions
serena replied to Mirek's topic in ARMA 3 - MISSION EDITING & SCRIPTING
// For example, we have in our mission: // - marker we want to shift, named MyMarker // - number of markers with predefined positions named SpawnLocation_01, SpawnLocation_02, ..., SpawnLocation_XX // Execute somewhere after mission initialization: "MyMarker" setMarkerPos getMarkerPos selectRandom (allMapMarkers select { _x find "SpawnLocation_" == 0});- 11 replies
-
- 1
-
- marker
- random position
-
(and 1 more)
Tagged with:
-
{Question} SImple Array Average
serena replied to froggyluv's topic in ARMA 3 - MISSION EDITING & SCRIPTING
private _result = allGroups apply {private _acc = 0; {_acc = _acc + skill _x} forEach units _x; _acc / count units _x} // Result: [0.4375,0.4375,1] private _result = allGroups apply {private _acc = 0; {_acc = _acc + skill _x} forEach units _x; [_x, _acc / count units _x]} // Result: [[B Alpha 1-1,0.4375],[B Alpha 1-2,0.4375],[B Alpha 1-3,1]] -
How To Get Location Names To Show Up On Screen
serena replied to Cerbium's topic in ARMA 3 - MISSION EDITING & SCRIPTING
GetAttributesForGivenLocationTypes = { private _lcs = []; { private _lct = _forEachIndex; { _lcs pushBack [text _x, _lct, locationPosition _x, direction _x, size _x, rectangular _x]; } forEach nearestLocations [getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition"), [_x], worldSize]; } forEach _this; _lcs }; // Usage: private _result = ["NameLocal", "NameVillage", "NameCity", "NameCityCapital"] call GetAttributesForGivenLocationTypes; // Result: // [ // ["airfield",0,[1697.19,5554.18,-5.5],0,[295.45,220.91],false], // ["military range",0,[3338.44,5744.44,-4.88803],0,[254.81,199.25],false], // ["Old Outpost",0,[4318.72,4398.14,-179.132],0,[121.02,90.49],false], // ["Kill Farm",0,[4449.56,6845.08,-91.6142],0,[236.36,176.73],false], // ["Xiros",0,[3712.09,7940.36,0.000755993],0,[236.36,176.73],false], // ... // ] -
Random pick in an array and _forEachIndex
serena replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Any syntax is allowed. You can use syntax that suits you best. Keyword effects and usage cases described here. Also good approach is to minimize allocation of variables where possible: private _idx = floor random count _pos_jose; _jose setPosAtl (_pos_jose select _idx); _jose setDir (_dir_jose select _idx); -
GEORGE FLOROS GR started following serena
-
Random pick in an array and _forEachIndex
serena replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
private _idx = floor random count _pos_jose; private _pos = _pos_jose select _idx; private _dir = _dir_jose select _idx; Because searching array in array of arrays operation is too slow -
This is an endless cycle that will never end (or never begin)
-
remove action when item dropped from inventory
serena replied to M1ke_SK's topic in ARMA 3 - MISSION EDITING & SCRIPTING
player addAction ["Drop Item", { }, [], 1.5, true, true, "", "'Item_Class_Name' in items player"]; -
How to create a function with optional params
serena replied to BlacKnightBK's topic in ARMA 3 - MISSION EDITING & SCRIPTING
https://community.bistudio.com/wiki/params https://community.bistudio.com/wiki/param My personal opinion: optional parameters impair the quality of the code, it is better to avoid using them if possible. -
Randomly count & select a marker by script
serena replied to Godis_1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yes private _last = _array param [count _array - 1]; Note, if array is empty you got nil value attempt to use which will cause an error. So, if you not sure array is not empty then use syntax with default value or check result before use: if (not isNil "_last") then { // code here executed only if _last variable contains value (array not empty) }; -
Randomly count & select a marker by script
serena replied to Godis_1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
// last element if array contains something, otherwise nothing: private _last = if (count _array < 1) then {nil} else {_array select (count _array - 1)}; // if you want to get default value when array empty - just replace nil constant: private _last = if (count _array < 1) then {"This is default value - array is empty"} else {_array select (count _array - 1)}; Another way is to use the param command: private _last = _array param [count _array - 1]; private _last = _array param [count _array - 1, "Default value - when array empty"]; -
Randomly count & select a marker by script
serena replied to Godis_1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
// function call _settlements call function_now; // inside function_now private _settlements = _this; // _this variable always references arguments passed to function -
Randomly count & select a marker by script
serena replied to Godis_1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
private _all = ["A", "B", "C", "D", "E"]; private _evn = []; private _odd = []; { if (_forEachIndex % 2 > 0) then {_evn pushBack _x} else {_odd pushBack _x} } forEach _all; // Result: // _evn = ["B","D"] // _odd = ["A","C","E"]