summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-26 07:09:20 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-26 07:09:20 -0400
commit568168fe1f62d757ce650b18a30336ab5f5d51f7 (patch)
tree6ae2ff66df076e37aaa662a426c522bedfab81c3
parentc005dc358adc8a47e744dc07f56d4ecff0358f9c (diff)
downloadunifieddyes-568168fe1f62d757ce650b18a30336ab5f5d51f7.tar
unifieddyes-568168fe1f62d757ce650b18a30336ab5f5d51f7.tar.gz
unifieddyes-568168fe1f62d757ce650b18a30336ab5f5d51f7.tar.bz2
unifieddyes-568168fe1f62d757ce650b18a30336ab5f5d51f7.tar.xz
unifieddyes-568168fe1f62d757ce650b18a30336ab5f5d51f7.zip
better handling of the register_on_placenode rotation fix
-rw-r--r--init.lua35
1 files changed, 19 insertions, 16 deletions
diff --git a/init.lua b/init.lua
index 39923a2..b736656 100644
--- a/init.lua
+++ b/init.lua
@@ -160,26 +160,29 @@ local default_dyes = {
minetest.register_on_placenode(
function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
local def = minetest.registered_items[newnode.name]
- if not def or not def.palette then return false end
- if string.find(itemstack:to_string(), "palette_index") then
- minetest.swap_node(pos, {name = newnode.name, param2 = newnode.param2})
- return
+
+ if not def
+ or not def.palette
+ or def.after_place_node then
+ return false
end
- local param2 = 0
- local color = 0
+ if not string.find(itemstack:to_string(), "palette_index") then
+ local param2 = 0
+ local color = 0
+
+ if def.palette == "unifieddyes_palette_extended.png" then
+ param2 = 240
+ color = 240
+ elseif def.palette == "unifieddyes_palette_colorwallmounted.png" then
+ param2 = newnode.param2 % 8
+ elseif def.palette ~= "unifieddyes_palette.png" then -- it's a split palette
+ param2 = newnode.param2 % 32
+ end
- if def.palette == "unifieddyes_palette_extended.png" then
- param2 = 240
- color = 240
- elseif def.palette == "unifieddyes_palette_colorwallmounted.png" then
- param2 = newnode.param2 % 8
- elseif def.palette ~= "unifieddyes_palette.png" then -- it's a split palette
- param2 = newnode.param2 % 32
+ minetest.swap_node(pos, {name = newnode.name, param2 = param2})
+ minetest.get_meta(pos):set_int("palette_index", color)
end
-
- minetest.swap_node(pos, {name = newnode.name, param2 = param2})
- minetest.get_meta(pos):set_int("palette_index", color)
end
)