Skip to content

Commit

Permalink
fixed #244
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed Jun 23, 2014
1 parent 529ad98 commit a4f0f3b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 32 deletions.
57 changes: 40 additions & 17 deletions AGM_Interaction/functions/fn_openMenu.sqf
@@ -1,33 +1,56 @@
// by commy2

if (player getVariable ["AGM_Unconscious", false]) exitWith {};

AGM_Interaction_Buttons = [];

_actions = [];
_class = _this;
if (_class == "") then {AGM_Interaction_Target = cursorTarget};

_object = AGM_Interaction_Target;

// search add-on config file
_config = configfile >> "CfgVehicles" >> typeOf _object >> "AGM_Actions";
if (_class != "") then {_config = _config >> _this};

_count = count _config;
if (_count == 0) exitWith {};
if (_count > 0) then {
for "_a" from 0 to (_count - 1) do {
_action = _config select _a;

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_distance = getNumber (_action >> "distance");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");

if ((_showDisabled || {call _condition}) && {player distance _object < _distance || {_distance == 0}}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
};
};
};
};

for "_a" from 0 to (_count - 1) do {
_action = _config select _a;

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_distance = getNumber (_action >> "distance");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");

if ((_showDisabled || {call _condition}) && {player distance _object < _distance || {_distance == 0}}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
// search mission config file
_config = missionConfigFile >> "CfgVehicles" >> typeOf _object >> "AGM_Actions";
if (_class != "") then {_config = _config >> _this};

_count = count _config;
if (_count > 0) then {
for "_a" from 0 to (_count - 1) do {
_action = _config select _a;

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_distance = getNumber (_action >> "distance");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");

if ((_showDisabled || {call _condition}) && {player distance _object < _distance || {_distance == 0}}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
};
};
};
};
Expand Down
52 changes: 37 additions & 15 deletions AGM_Interaction/functions/fn_openMenuSelf.sqf
@@ -1,31 +1,53 @@
// by commy2

if (player getVariable ["AGM_Unconscious", false]) exitWith {};

AGM_Interaction_Buttons = [];

_actions = [];
_class = _this;

_object = vehicle player;

// search add-on config file
_config = configfile >> "CfgVehicles" >> typeOf _object >> "AGM_SelfActions";
if (_class != "") then {_config = _config >> _this};

_count = count _config;
if (_count == 0) exitWith {};

for "_a" from 0 to (_count - 1) do {
_action = _config select _a;
if (_count > 0) then {
for "_a" from 0 to (_count - 1) do {
_action = _config select _a;

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");

if (_showDisabled || {call _condition}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
};
};
};
};

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");
// search mission config file
_config = missionConfigFile >> "CfgVehicles" >> typeOf _object >> "AGM_SelfActions";
if (_class != "") then {_config = _config >> _this};

if (_showDisabled || {call _condition}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
_count = count _config;
if (_count > 0) then {
for "_a" from 0 to (_count - 1) do {
_action = _config select _a;

if (count _action > 0) then {
_displayName = getText (_action >> "displayName");
_condition = compile getText (_action >> "condition");
_statement = compile getText (_action >> "statement");
_showDisabled = getNumber (_action >> "showDisabled") == 1;
_priority = getNumber (_action >> "priority");

if (_showDisabled || {call _condition}) then {
_actions set [count _actions, [_displayName, _statement, _condition, _priority]];
};
};
};
};
Expand Down

1 comment on commit a4f0f3b

@robinhoersch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Please sign in to comment.