From c12e3cdf3fc089e1bca7122870bcc452a6cfe4f3 Mon Sep 17 00:00:00 2001 From: philipmi Date: Tue, 11 Apr 2023 17:26:17 +0200 Subject: [PATCH] Fix crash with MT 5.7.0 and update mtg fencegate registration --- mods/mtg/doors/init.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mods/mtg/doors/init.lua b/mods/mtg/doors/init.lua index 240134d..be5c463 100644 --- a/mods/mtg/doors/init.lua +++ b/mods/mtg/doors/init.lua @@ -723,7 +723,7 @@ function doors.register_fencegate(name, def) local fence = { description = def.description, drawtype = "mesh", - tiles = {def.texture}, + tiles = {}, paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, @@ -734,8 +734,8 @@ function doors.register_fencegate(name, def) sounds = def.sounds, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local node_def = minetest.registered_nodes[node.name] - minetest.swap_node(pos, {name = node_def.gate, param2 = node.param2}) - minetest.sound_play(node_def.sound, {pos = pos, gain = 0.3, + minetest.swap_node(pos, {name = node_def._gate, param2 = node.param2}) + minetest.sound_play(node_def._gate_sound, {pos = pos, gain = 0.3, max_hear_distance = 8}) return itemstack end, @@ -745,6 +745,16 @@ function doors.register_fencegate(name, def) }, } + + if type(def.texture) == "string" then + fence.tiles[1] = {name = def.texture, backface_culling = true} + elseif def.texture.backface_culling == nil then + fence.tiles[1] = table.copy(def.texture) + fence.tiles[1].backface_culling = true + else + fence.tiles[1] = def.texture + end + if not fence.sounds then fence.sounds = default.node_sound_wood_defaults() end @@ -753,8 +763,8 @@ function doors.register_fencegate(name, def) local fence_closed = table.copy(fence) fence_closed.mesh = "doors_fencegate_closed.obj" - fence_closed.gate = name .. "_open" - fence_closed.sound = "doors_fencegate_open" + fence_closed._gate = name .. "_open" + fence_closed._gate_sound = "doors_fencegate_open" fence_closed.collision_box = { type = "fixed", fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, @@ -762,8 +772,8 @@ function doors.register_fencegate(name, def) local fence_open = table.copy(fence) fence_open.mesh = "doors_fencegate_open.obj" - fence_open.gate = name .. "_closed" - fence_open.sound = "doors_fencegate_close" + fence_open._gate = name .. "_closed" + fence_open._gate_sound = "doors_fencegate_close" fence_open.groups.not_in_creative_inventory = 1 fence_open.collision_box = { type = "fixed",