Skip to content

Commit

Permalink
Merge pull request #12 from SwissalpS/suggestNotSwappingMultipleTimes
Browse files Browse the repository at this point in the history
Suggest not swapping multiple times
  • Loading branch information
6r1d committed Oct 17, 2020
2 parents c9e80da + cea1b81 commit c985e23
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions rgb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,34 @@ local digiline_action = function(pos, node, channel, mixed_msg)
else
return
end
local changed = false
-- Set color
if (msg.color ~= nil) and (type(msg.color) == 'string' or type(msg.color) == 'number') then
node.param2 = msg.color
minetest.swap_node(pos, node)
changed = true
end
-- Enable / disable glow
if nil ~= msg.switch then
if 0 == msg.switch then
minetest.swap_node(pos, {name = 'new_glass:rgb_off', param2 = node.param2 })
changed = true
node.name = 'new_glass:rgb_off'
else
minetest.swap_node(pos, {name = 'new_glass:rgb_on', param2 = node.param2 })
changed = true
node.name = 'new_glass:rgb_on'
end
end
-- Reset handler (int)
if msg.reset ~= nil and type(msg.reset) == 'number' then
if msg.reset >= 1 then
changed = true
-- I am hardcoding a param2, because for some reason it has a default value
minetest.swap_node(pos, {name = 'new_glass:rgb_off', param2 = 240 })
node = { name = 'new_glass:rgb_off', param2 = 240 }
end
end

if changed then
minetest.swap_node(pos, node)
end
end

local handle_construct = function(pos)
Expand Down Expand Up @@ -150,4 +158,3 @@ if minetest.get_modpath('unifieddyes') and minetest.get_modpath('digilines') the
register_rgb_glass('new_glass:rgb_off', 0)
register_rgb_glass('new_glass:rgb_on', 14)
end

0 comments on commit c985e23

Please sign in to comment.