DenVdmj
Member-
Content Count
14 -
Joined
-
Last visited
-
Medals
Community Reputation
0 NeutralAbout DenVdmj
-
Rank
Private First Class
Contact Methods
-
Youtube
http://www.youtube.com/user/Denisk0Redisk0
-
sqf syntax highlighting schemes generator
DenVdmj posted a topic in ARMA 2 & OA : Community Made Utilities
SQF syntax highlighting schemes generator for following editors: SciTE, FAR+Colorer, Notepad++, Sublime Text 2, softwaremaniacs js highlighter (http://softwaremaniacs.org/soft/highlight/en/) Schemes are located in the folder "schemes". Run the script "make.luaj" (or "make-schemes.cmd") for updates. Download here -
Arrays.sqf (howto)?
DenVdmj replied to _Mofo_'s topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
when i tried to execute "true == true" i got the error: Error in expression <true == true> Error position: <== true> Error ==: Type Bool, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location Error in expression <true == true> Error position: <== true> Error Generic error in expression Also, in other cases, for compare boolean values can be used xor: #define __xor(a,b) (!((a)&&(b))&&((a)||(b))) hm.. yes, statement "objNull in [objNull]" be true, and this is different with "objNull == objNull". i think that this behavior is necessary to specify in the function description. -
Arrays.sqf (howto)?
DenVdmj replied to _Mofo_'s topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Hi guys. You forget about the other types, which can't be compared with "==" operator. Such as "BOOL", "CODE", "DIARY_RECORD", "SCRIPT", "TASK" #define def(name) private #name; name #define arg(i) (_this select (i)) func_isEqual = { def(_a) = arg(0); def(_b) = arg(1); if (isNil "_a") exitWith { isNil "_b" }; if (typeName _a != typeName _b) exitWith { false }; if (typeName _a in [ "BOOL", "CODE", "DIARY_RECORD", "SCRIPT", "TASK" ]) exitWith { _a in [_b] }; if (typeName _a in [ "SCALAR", "STRING", "OBJECT", "SIDE", "GROUP", "TEXT", "CONFIG", "DISPLAY", "CONTROL", "TEAM_MEMBER" ]) exitWith { _a == _b }; if (typeName _a != "ARRAY") exitWith { // namespace type and others false }; if (count _a != count _b) exitWith { false }; for "_i" from 0 to count _a - 1 do { if !([_a select _i, _b select _i] call func_isEqual) exitWith { false }; true; }; }; // simplified version (and case sensitive string comparison) func_isEqual_2 = { def(_a) = arg(0); def(_b) = arg(1); if (isNil "_a") exitWith { isNil "_b" }; if (typeName _a != typeName _b) exitWith { false }; if (typeName _a != "ARRAY") exitWith { _a in [_b] }; if (count _a != count _b) exitWith { false }; for "_i" from 0 to count _a - 1 do { if !([_a select _i, _b select _i] call func_isEqual_2) exitWith { false }; true; }; }; // replace all \xA0 to \x20 after copy&paste (f..ng parser) -
SQF Syntax Highlighter for Sublime Text 2
DenVdmj replied to jonbons's topic in ARMA 2 & OA : Community Made Utilities
Great! Good highlighting for the most fappable editor )) Doesn't work highlighting for the hex values, like an 0xA0 -
Squint - the sqf editor and error-checker
DenVdmj replied to sbsmac's topic in ARMA 2 & OA : Community Made Utilities
Sbsmac, thanks you for a good sqf-tidy. It has almost correct sqf parser :) Here are some tough tests: funcTestForSquint = { private ["_cond", "_func", "_code1", "_code2"]; _func = if (count _this > 2) then {{ player sideChat "count _this > 2" }} else {{ player sideChat "count _this <= 2" }}; _cond = if (typeName (_this select 0) == "CODE"); _code1 = { player sideChat "it _code1"; call _func }; _code2 = { player sideChat "it _code2"; call _func }; _cond then _code1 else _code2; }; private ["_printHello", "_for_i", "_for_i_from_1", "_do_ten_times"]; // Almost good! _printHello = { diag_log "Hello!" }; _for_i = for "_i"; _for_i_from_1 = _for_i from 1; _do_ten_times = _for_i_from_1 to 10; _do_ten_times do _printHello; // Squint removes the number 1e+99! someValue = 1e+99;; // 1.#INF Another test: -
This is done using namespaces, a stack of windows and the fact that at the time of disconnection from the server, still have connection.
-
Formally, this is the correct code. Respectively, checker (formally correct checker) should recognize it as valid. (otherwise, what is the profit of checking?) In SQF every command has one of the three basic syntactic forms. Most of the commands more correctly be called "operators", and below we see why. 1) No-operand form, either a constant, such as "west", "pi", or "access function" such as "player", "overcast". 2) Single operand from, such as unary operators "-", "not" in Pascal or operators "!", "new", "delete" in C++. In SQF it is a "if", "switch", "for", unary "-", "!", "not", and others. 3) Two-operands form, operators such as "*", "/", "or", "and" of Pascal. In SQF, this syntactic group includes follows operators: "then", "else", "do", "from", "to", "*", "/", "&&", "and", "||", "or", and others. What is my point: SQF has little to do with us habitual programming languages. And if in other languages "if then else" - is the basic syntax, then in the SQF is a just expression, wich syntactically no different from the "! ((Pi / 6) == (someVar * 120))" There are many other differing languages, such as Forth, LISP, Haskel, etc. We can't be consider that is only one scripting style is right style, style that more similar to C way, but less to the LISP way (for example). The maximum, that can afford code checker, it is warnings only: "your code doesn't look like the C++ code!".
-
(many screens) We can't have the same approach to the interpreted language with dynamic typing, as to the usual C++. In terms of sqf-compiler, the following (obviously wrong) expressions are valid: 123 = qwe / player // check: compile "123 = qwe / player" Why try to be smarter than the compiler? The language doesn't have syntactic structures such as: "if the else" or "while do", these are just the several operators, such as "-", "+". But let's look further: the following expressions are valid (also) in terms of semantics (correct, in fact): _printHello = { diag_log "Hello!" }; _for_i = for "_i"; _for_i_from_1 = _for_i from 1; _do_ten_times = _for_i_from_1 to 10; _do_ten_times do _printHello; ((( for "_i" ) from 10 ) to 12 ) do { player sideChat str _i } _always = if true; _never = if false; // almost from real code: // caseignored "in": if (_regionType in _requestedTypes) then { ... } { if (_x == _regionType) exitwith { _always }; _never } foreach _requestedTypes then { _distance = getArray (_cfgRegion >> "position") distance _position; if (_distance < _minDistance) then { _minDistance = _distance; _nearestRegion = _cfgRegion; }; }; _print_a_is_a = { hint "a is a" }; _print_a_isnt_a = { hint "a is not a" }; (switch a) call { _this do { case "a" : _always; default _never; } } call { _this then (_print_a_is_a else _print_a_isnt_a) }; How do you test it? In all other respects - a very useful tool! PS. sorry for my lang
-
It's true. There is a way to run scripts at any arma2 server. This method doesn't use any addons, doesn't use the merge config, and can't be detected using any methods. This loophole can be closed only by arma2 developers.
-
group limit reached due to respawns
DenVdmj replied to dematti's topic in ARMA 2 & OA : ADDONS - Configs & Scripting
What’s going down? Maybe something like this would be more stably: // init code _logic = createGroup createCenter sideLogic createUnit ["logic", [0,0,0], [], 0, "none"]; missionNamespace setVariable ["/YourModPrefix/SpecialGroupForDeadUnits", group _logic]; -
group limit reached due to respawns
DenVdmj replied to dematti's topic in ARMA 2 & OA : ADDONS - Configs & Scripting
Test (non-working example): _g = group _someUnit; { _x setDammage 1 } foreach units _g; hint str count units _g; deleteGroup _g; if( !isNull _g ) then { hint "Error!" }; the working example: _g = group _someUnit; { deleteVehicle _x } foreach units _g; hint str count units _g; deleteGroup _g; if( isNull _g ) then { hint "Ok" }; The group can't be deleted if it still contains the units. Whether alive or dead. In your case _unitsGroup not contains the dead soldiers. Insert this test before code "deleteGroup _group;" (AI_respawn.sqf): if( count units _group > 0 ) exitwith { "Error!" call { diag_log _this; hint _this; }; }; Another test: _g = group _unit; { _x setDammage 1 } foreach units _g; hint str count units _g; deleteGroup _g; player sideChat str _g; units _g joinsilent player; deleteGroup _g; player sideChat str _g; So, the solution may be as follows: // init code missionNamespace setVariable ["/YourModPrefix/SpecialGroupForDeadUnits", createGroup createCenter sideLogic]; // in AI_respawn.sqf units _group joinSilent (missionNamespace getVariable "/YourModPrefix/SpecialGroupForDeadUnits"); deleteGroup _group; // Or the best way: { _x addEventHandler ["killed", { _group = group (_this select 0); if( { alive _x } count units _group == 0 ) then { units _group joinSilent (missionNamespace getVariable "/YourModPrefix/SpecialGroupForDeadUnits"); deleteGroup _group; execVM "spawnNewGroup.sqf"; }; }]; } foreach units _group; -
group limit reached due to respawns
DenVdmj replied to dematti's topic in ARMA 2 & OA : ADDONS - Configs & Scripting
Groups are created and deleted properly, the command deleteGroup works correctly: _allGroup = allGroups - [group player]; _count = count _allGroup min 10; _offset = floor random (count _allGroup - _count); for "_i" from 0 to _count - 1 do { _group = _allGroup select (_i + _offset); { deleteVehicle _x } foreach units _group; deleteGroup _group; }; for "_i" from 0 to 1000 do { _group = createGroup createCenter side player; if(isNull _group) exitwith { _j = 0; { if(count units _x < 1) then { _j = _j + 1; }; } foreach allGroups; hint format [ "Created %1 groups\nDeleted %2 groups, [%3 .. %4]\nTotal void groups: %5", _i, _count, _offset, _count + _offset, _j ]; }; for "_i" from 0 to 5 do { _group createUnit [typeof player, getpos player, [], 1000, "none"]; }; }; Could you post the minimal code that demonstrates your problem? -
Converting Strings
DenVdmj replied to ColonelSandersLite's topic in ARMA - MISSION EDITING & SCRIPTING
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> /* Â Â Based on Vova _Fox version. Â Â "string" call compile preprocessfile "str2arr\str2arr_bin.sqf" Â Â "str[]"" ""@#$$ QWERing" call compile preprocessfile "str2arr\str2arr_bin.sqf" Â Â "str[]"" ""@ASDF Â : = + ) ( [ ]#$$ QWERing" call compile preprocessfile "str2arr\str2arr_bin.sqf" */ private ["_strs", "_array", "_prev", "_padding", "_char", "_chars", "_substr"]; _chars = [ Â Â " ","!","""","#","$","%","&","'","(",")","*","+",",","-",".","/", Â Â "0","1","2","3","4","5","6","7","8","9", Â Â ":",";","<","=",">","?","@", Â Â "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", Â Â "[","\","]","^","_","`", Â Â "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", Â Â "{","|","}","~","" ]; _strs = [" "]; for "_i" from 0 to 10 do { Â Â _prev = _strs select _i; Â Â _strs set [count _strs, _prev + _prev] }; _array = []; _prev = ""; for "_i" from 2045 to 0 step -1 do { Â Â _padding = ""; Â Â for "_j" from 0 to 10 do { Â Â Â Â if( floor( ( _i/(2^_j) ) % 2 ) == 1 )then{ Â Â Â Â Â Â _padding = _padding + (_strs select _j) Â Â Â Â } Â Â }; Â Â _substr = call compile (format["%1'%2", _padding, _this] + "'"); Â Â if( isnil "_substr" )exitWith{}; Â Â if( _prev == _substr )exitWith{}; Â Â _char = { if( _substr in [_prev+_x] )exitWith{ _x }; "" } foreach _chars; Â Â _array set [count _array, _char]; Â Â _prev = _substr; }; _array -
Converting Strings
DenVdmj replied to ColonelSandersLite's topic in ARMA - MISSION EDITING & SCRIPTING
Another version: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> /* Â Â Based on Vova _Fox version. Â Â "string" call compile preprocessfile "str2arr\str2arr1.sqf" Â Â "st""wqerr_!@#$@#$ASDring" call compile preprocessfile "str2arr\str2arr1.sqf" */ private ["_prev", "_char", "_bigstr", "_chars", "_substr", "_padding", "_array"]; _chars = [ Â Â " ","!","""","#","$","%","&","'","(",")","*","+",",","-",".","/", Â Â "0","1","2","3","4","5","6","7","8","9", Â Â ":",";","<","=",">","?","@", Â Â "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", Â Â "[","\","]","^","_","`", Â Â "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", Â Â "{","|","}","~","" ]; _bigstr = " "; _padding = ""; _array = []; _prev = ""; // _bigstr length == 2048 for "" from 0 to 10 do { _bigstr = _bigstr + _bigstr }; for "" from 0 to 2045 do { Â Â _padding = _padding + " "; Â Â _substr = call compile (format["%1'%2", call compile (format["%1'%2", _padding, _bigstr] + "'"), _this] + "'"); Â Â if( isnil "_substr" )exitWith{}; Â Â if( _prev == _substr )exitWith{}; Â Â _char = { if( _substr in [_prev+_x] )exitWith{ _x }; "" } foreach _chars; Â Â _array set [count _array, _char]; Â Â _prev = _substr; }; _array