ACE3/addons/common/functions/fnc_getStringFromMissionSQM.sqf

71 lines
1.5 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
2015-09-21 11:08:10 +00:00
* Get a string from the mission.sqm file. Mission has to be saved in the Editor.
* The string cannot contain the ; character.
* If the entry does not exist, it might return an empty string or an entry with the same name of another class!
*
2015-09-21 11:08:10 +00:00
* Arguments:
* 0: Path of the entry in the mission.sqm <ARRAY>
*
2015-09-21 11:08:10 +00:00
* Return Value:
* Value of the entry. <STRING>
*
2015-09-21 11:08:10 +00:00
* Public: No
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-21 11:08:10 +00:00
private ["_path", "_mission", "_class", "_index", "_array", "_entry"];
_path = _this;
if (missionName == "") exitWith {""};
2015-09-21 11:08:10 +00:00
_mission = toArray toLower loadFile "mission.sqm";
_mission resize 65536;
2015-09-21 11:08:10 +00:00
{
2015-05-14 18:06:06 +00:00
if (_x < 33) then {
_mission set [_forEachIndex, -1];
}
} forEach _mission;
2015-09-21 11:08:10 +00:00
_mission = toString (_mission - [-1]);
{_path set [_forEachIndex, toLower _x]} forEach _path;
for "_a" from 0 to (count _path - 2) do {
2015-05-14 18:06:06 +00:00
_class = format ["class%1{", _path select _a];
2015-05-14 18:06:06 +00:00
_index = _mission find _class;
2015-05-14 18:06:06 +00:00
_array = toArray _mission;
2015-09-21 11:08:10 +00:00
2015-05-14 18:06:06 +00:00
for "_b" from 0 to (_index + count toArray _class - 1) do {
_array set [_b, -1];
};
2015-09-21 11:08:10 +00:00
2015-05-14 18:06:06 +00:00
_array = _array - [-1];
2015-05-14 18:06:06 +00:00
_mission = toString _array;
};
_entry = format ["%1=", _path select (count _path - 1)];
_index = _mission find _entry;
2015-09-21 11:08:10 +00:00
if (_index == -1) exitWith {""};
_array = toArray _mission;
2015-09-21 11:08:10 +00:00
for "_b" from 0 to (_index + count toArray _entry - 1) do {
2015-05-14 18:06:06 +00:00
_array set [_b, -1];
};
2015-09-21 11:08:10 +00:00
_mission = toString (_array - [-1]);
_index = _mission find ";";
_mission = toArray _mission;
_mission resize _index;
2015-09-21 11:08:10 +00:00
format ["%1", toString _mission] // return