mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-11-22 15:33:52 +01:00
better handling of the register_on_placenode rotation fix
This commit is contained in:
parent
c005dc358a
commit
568168fe1f
35
init.lua
35
init.lua
@ -160,26 +160,29 @@ local default_dyes = {
|
|||||||
minetest.register_on_placenode(
|
minetest.register_on_placenode(
|
||||||
function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
|
function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
|
||||||
local def = minetest.registered_items[newnode.name]
|
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
|
if not def
|
||||||
minetest.swap_node(pos, {name = newnode.name, param2 = newnode.param2})
|
or not def.palette
|
||||||
return
|
or def.after_place_node then
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local param2 = 0
|
if not string.find(itemstack:to_string(), "palette_index") then
|
||||||
local color = 0
|
local param2 = 0
|
||||||
|
local color = 0
|
||||||
|
|
||||||
if def.palette == "unifieddyes_palette_extended.png" then
|
if def.palette == "unifieddyes_palette_extended.png" then
|
||||||
param2 = 240
|
param2 = 240
|
||||||
color = 240
|
color = 240
|
||||||
elseif def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
elseif def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
||||||
param2 = newnode.param2 % 8
|
param2 = newnode.param2 % 8
|
||||||
elseif def.palette ~= "unifieddyes_palette.png" then -- it's a split palette
|
elseif def.palette ~= "unifieddyes_palette.png" then -- it's a split palette
|
||||||
param2 = newnode.param2 % 32
|
param2 = newnode.param2 % 32
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.swap_node(pos, {name = newnode.name, param2 = param2})
|
||||||
|
minetest.get_meta(pos):set_int("palette_index", color)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = newnode.name, param2 = param2})
|
|
||||||
minetest.get_meta(pos):set_int("palette_index", color)
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user