The RTG Guy
Member
So I was researching on Lua code and I looked up Mobj color. This code popped up on Google AI. Can someone fact-check?
Lua Code:
-- Example: Change the player's skin to red when a button is pressed
addHook("ThinkFrame", function()
if not Local.Player then return end
if Local.Player.mo.skin ~= "Sonic.Skin.Red" and Local.Player.buttons & BT_CUSTOM1 then
Local.Player.mo.skin = "Sonic.Skin.Red"
P_SetMobjState(Local.Player.mo, Local.Player.mo.state) -- Force state update
elseif Local.Player.mo.skin == "Sonic.Skin.Red" and not (Local.Player.buttons & BT_CUSTOM1) then
Local.Player.mo.skin = "Sonic.Skin.Blue" -- Or the player's original skin
P_SetMobjState(Local.Player.mo, Local.Player.mo.state)
end
end)