ACE3/addons/common/functions/fnc_readSettingsFromParamsArray.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

68 lines
2.5 KiB
Plaintext

#define DEBUG_MODE_FULL
#include "script_component.hpp"
/*
* Author: PabstMirror
* Read settins from paramsArray that have a ACE_setting = 1.
* Happens before modules but after all other configs (for force priority)
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_common_fnc_readSettingsFromParamsArray
*
* Public: No
*/
//paramsArray is a normal variable not a command
private _paramsArray = missionnamespace getVariable ["paramsArray", []];
TRACE_1("Reading missionConfigFile params",_paramsArray);
{
private _config = (missionConfigFile >> "params") select _forEachIndex;
if ((getNumber (_config >> "ACE_setting")) > 0) then {
private _settingName = configName _config;
private _settingValue = _x;
private _title = getText (_config >> "title");
TRACE_3("ace_setting",_title,_settingName,_settingValue);
// Check if the variable is already defined
if (isNil _settingName) exitWith {
ERROR_1("readSettingsFromParamsArray - param [%1] is not an ace_setting", _settingName);
};
// The setting is not forced, so update the value
// Read entry and cast it to the correct type from the existing variable
(cba_settings_default getVariable [_settingName, []]) params ["", "", ["_settingType", ""]];
private _validValue = false;
switch (true) do {
case (_settingType == "LIST");
case (_settingType == "SCALAR"): {
_validValue = [_settingName, _settingValue] call CBA_settings_fnc_check;
};
case (_settingType == "CHECKBOX"): {
_settingValue = _settingValue > 0;
_validValue = [_settingName, _settingValue] call CBA_settings_fnc_check;
};
// Will not Handle ARRAY,COLOR,STRING??? (bool/scalar covers most important settings)
};
if (!_validValue) exitWith {
WARNING_3("readSettingsFromParamsArray - param [%1] type not valid [%2] - expected type [%3]", _settingName,_settingValue,_settingType);
};
if ([_settingName, "mission"] call CBA_settings_fnc_isForced) then {
WARNING_1("Setting [%1] - Already Forced",_settingName);
};
// Set the setting as a mission setting and force it
private _return = ["CBA_settings_setSettingMission", [_settingName, _settingValue, true]] call CBA_fnc_localEvent;
TRACE_3("setSettingMission from paramsArray",_settingName,_settingValue,_return);
};
} forEach _paramsArray;