Avoid accessing state variables within pings
The host instance of the variable should be authoritative to ensure host and clients are in sync
This commit is contained in:
parent
776de24593
commit
042405cb63
17
script.lua
17
script.lua
@ -3,6 +3,8 @@
|
|||||||
-- Texture dimensions --
|
-- Texture dimensions --
|
||||||
TEXTURE_WIDTH = 128
|
TEXTURE_WIDTH = 128
|
||||||
TEXTURE_HEIGHT = 128
|
TEXTURE_HEIGHT = 128
|
||||||
|
|
||||||
|
-- local state variables (do not access within pings) --
|
||||||
armor_enabled=true
|
armor_enabled=true
|
||||||
vanilla_enabled=true
|
vanilla_enabled=true
|
||||||
|
|
||||||
@ -116,7 +118,7 @@ end
|
|||||||
action_wheel.SLOT_2.setTitle('log health')
|
action_wheel.SLOT_2.setTitle('log health')
|
||||||
action_wheel.SLOT_2.setFunction(function() print(player.getHealth()) end)
|
action_wheel.SLOT_2.setFunction(function() print(player.getHealth()) end)
|
||||||
action_wheel.SLOT_3.setTitle('Toggle Armor')
|
action_wheel.SLOT_3.setTitle('Toggle Armor')
|
||||||
action_wheel.SLOT_3.setFunction(function() ping.setArmor() end)
|
action_wheel.SLOT_3.setFunction(function() setArmor() end)
|
||||||
|
|
||||||
-- Pings --
|
-- Pings --
|
||||||
--- Damage function --
|
--- Damage function --
|
||||||
@ -130,16 +132,19 @@ end
|
|||||||
function ping.healed(health)
|
function ping.healed(health)
|
||||||
setExpression(0,0)
|
setExpression(0,0)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggle Armor ---
|
--- Toggle Armor ---
|
||||||
function ping.setArmor(enabled)
|
function setArmor(state)
|
||||||
if enabled == nil then
|
if state == nil then
|
||||||
armor_enabled=not armor_enabled
|
armor_enabled=not armor_enabled
|
||||||
else
|
else
|
||||||
armor_enabled=enabled
|
armor_enabled=state
|
||||||
end
|
end
|
||||||
|
ping.setArmor(state)
|
||||||
|
end
|
||||||
|
function ping.setArmor(state)
|
||||||
for key, value in pairs(armor_model) do
|
for key, value in pairs(armor_model) do
|
||||||
value.setEnabled(armor_enabled)
|
value.setEnabled(state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user