Created
April 10, 2021 18:22
-
-
Save matshou/d91f9836f4fb67ee90b9cef80b77b556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---Returns fog instance. | |
---@return ClimateManager.ClimateFloat | |
local function getFogIntensity() | |
return getClimateManager():getClimateFloat(5); | |
end | |
---Update fog intensity with given value | |
---@param value Float | |
local function updateFogIntensity(value) | |
local fogIntensity = getFogIntensity() | |
fogIntensity:setAdminValue(fogIntensity:getAdminValue() + value); | |
print("colFog: fog value updated to " .. fogIntensity:getAdminValue()); | |
end | |
---Toggle fog in-game state on/off. | |
local function toggleFog() | |
---@type ClimateManager.ClimateFloat | |
local fog = getFogIntensity() | |
if (fog:isEnableAdmin()) then | |
fog:setEnableAdmin(false) | |
else | |
fog:setEnableAdmin(true) | |
end | |
print("colFog: changed admin state to " .. tostring(fog:isEnableAdmin())) | |
end | |
---Change color of the fog to given color. | |
---@param color Color | |
local function changeFogColor(color) | |
---@type ClimateManager.ClimateColor | |
local climateColor = getClimateManager():getClimateColor(1) | |
climateColor:setEnableAdmin(true) | |
---@type Color | |
local exteriorColor = climateColor:getAdminValue():getExterior() | |
print("colFog: current fog color " .. exteriorColor:toString()) | |
exteriorColor:set(color) | |
print("colFog: changed fog color to " .. exteriorColor:toString()) | |
end | |
Events.OnCustomUIKeyPressed.Add(function(key) | |
if key == Keyboard.KEY_1 then | |
toggleFog() | |
elseif key == Keyboard.KEY_2 then | |
updateFogIntensity(0.1) | |
elseif key == Keyboard.KEY_3 then | |
updateFogIntensity(-0.1) | |
elseif key == Keyboard.KEY_4 then | |
changeFogColor(Color.red) | |
elseif key == Keyboard.KEY_5 then | |
changeFogColor(Color.green) | |
elseif key == Keyboard.KEY_6 then | |
changeFogColor(Color.blue) | |
end | |
end); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment