switch from loadFile to preprocessFile and dusted off the regex brain cell

This commit is contained in:
lambdatiger 2024-01-10 00:17:56 -06:00
parent 98fd580540
commit 1e93453963

View File

@ -28,16 +28,17 @@ if !(isNil "_material") exitWith {
if (isClass (configFile >> "CfgSurfaces" >> _surfType)) then { if (isClass (configFile >> "CfgSurfaces" >> _surfType)) then {
_material = getText (configFile >> "CfgSurfaces" >> _surfType >> "soundEnviron"); _material = getText (configFile >> "CfgSurfaces" >> _surfType >> "soundEnviron");
} else { // Messy way when a surface isn't added to cfgSurfaces } else { // Messy way when a surface isn't added to cfgSurfaces
private _surfFileText = loadFile _surfType; private _surfFileText = tolower preprocessFile _surfType;
_surfFileText = (tolower _surfFileText) splitString " "";="+ endl; _surfFileText = _surfFileText regexReplace ["[^A-Za-z0-9]", ""];
private _idx = _surfFileText find "soundenviron"; private _idx = 12 + (_surfFileText find "soundenviron");
_material = _surfFileText#(_idx+1); if (_surfFileText select [_idx, 5] isEqualTo "empty") then {
if (_material isEqualTo "empty") then { _idx = 8 + (_surfFileText find "soundhit");
_idx = _surfFileText find "soundhit"; _material = _surfFileText select [_idx, 10];
_material = _surfFileText#(_idx+1); } else {
}; _material = _surfFileText select [_idx, 10];
};
}; };
TRACE_1("soundFound",_material); TRACE_1("materialSubString",_material);
_material = switch (true) do { _material = switch (true) do {