Femboy Access
-
Автор темы
- #1
shadows.lua:
--[[const]] local TAB = "Visuals"
--[[const]] local CONTAINER = "Effects"
--[[const]] local f = string.format
-- --- --
--[[const]] local dirs = { 'x', 'y', 'z' }
--[[const]] local netvars = { -- Don't invegistate CCascadeLight netvars further. You will waste your time, lol.
{ "Shadow direction", "m_shadowDirection", "vector" },
{ "Light direction", "m_envLightShadowDirection", "vector" },
{ "Shadow overlay color", "m_LightColor", "color32" },
{ "Shadow intensivity", "m_LightColorScale", "int", 0, 650, 255 },
{ "Shadow max render distance", "m_flMaxShadowDist", "int", 0, 1000, 400 },
}
-- --- --
local function color_to_int32(_1, _2, _3, _4)
return bit.bor(bit.lshift(_4, 24), bit.lshift(_3, 16), bit.lshift(_2, 8), _1)
end
-- --- --
local ui_elems = {}
for _, netvar in next, netvars do
if netvar[3] == "vector" then
ui.new_label(TAB, CONTAINER, netvar[1])
local vec = {}
for _, dir in next, dirs do
vec[#vec+1] = ui.new_slider(
TAB, CONTAINER, f("\n %s %s", netvar[1], dir),
-100, 100, 0, --[[show_tooltip]] true, --[[unit]] "", --[[scale]] 0.01
)
end
ui_elems[netvar[2]] = vec
elseif netvar[3] == "color32" then
ui.new_label(TAB, CONTAINER, netvar[1])
ui_elems[netvar[2]] = ui.new_color_picker(TAB, CONTAINER, netvar[1], 251, 211, 164, 255)
elseif netvar[3] == "int" then
ui_elems[netvar[2]] = ui.new_slider(TAB, CONTAINER, netvar[1], netvar[4], netvar[5], netvar[6])
end
end
-- --- --
client.set_event_callback("paint", function()
local ent = entity.get_all("CCascadeLight")[1]
if (ent == nil or ent == 0) then
return
end
for netvar, ui_elem in next, ui_elems do
if type(ui_elem) == "table" then -- if ui_elem is vector
local vec = {}
for idx, dir in next, ui_elem do
vec[idx] = ui.get(dir) * 0.01
end
entity.set_prop(ent, netvar, unpack(vec))
elseif ui.type(ui_elem) == "color_picker" then
entity.set_prop(ent, netvar, color_to_int32(ui.get(ui_elem)))
else
entity.set_prop(ent, netvar, ui.get(ui_elem))
end
end
end)