TODO:
* Also set `setObjectViewDistance _distance`
* use diag_fps directly, no array
# Anfangswerte setzen und bisherige Hintergrundskripte beenden
setViewDistance 6000;
niCe_autoViewDistance = false;
sleep 0.3;
# Debugausgabe innerhalb der Schleife
systemChat format ["median FPS: %1, viewDistance: %2, %3", median_fps, viewDistance, fps];
Version 1:
missionNamespace setVariable ["_automaticViewDistance", true];
0 spawn {
_fps = [60];
_maxDistance = viewDistance;
while { uiSleep 0.3; missionNamespace getVariable "_automaticViewDistance" } do {
_fps pushBack diag_fps;
_fps sort true;
_median_fps = _fps deleteAt 5;
_distance = viewDistance;
if (_median_fps < 30) then { _distance = _distance - 100 };
if (_median_fps > 45) then { _distance = _distance + 100 };
if ((_distance min _maxDistance) <= _maxDistance) then { setViewDistance _distance };
};
};
Zum Ausschalten:
missionNamespace setVariable ["_automaticViewDistance", false];
Zum Testen und Entwickeln:
[spoiler]
# Anfangswerte setzen und bisherige Hintergrundskripte beenden
setViewDistance 6000;
missionNamespace setVariable ["_automaticViewDistance", false];
sleep 0.3;
# Debugausgabe innerhalb der Schleife
systemChat format ["median FPS: %1, viewDistance: %2, %3", _median_fps, viewDistance, _fps];