From 15b0e749fda72c1be65501d0e7ae900a22431c3a Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Fri, 2 Aug 2019 20:38:24 +0000 Subject: [PATCH 1/7] fix workbench inv movement bug; add protection checking --- src/workbench.lua | 81 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/src/workbench.lua b/src/workbench.lua index 097c585..53e4712 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -1,3 +1,7 @@ +local function log(level, message, ...) + minetest.log(level, '[xdecor] ' .. message:format(...)) +end + local workbench = {} WB = {} screwdriver = screwdriver or {} @@ -69,7 +73,7 @@ function workbench:get_output(inv, input, name) local item = name .. "_" .. nbox[1] item = nbox[3] and item or "stairs:" .. nbox[1] .. "_" .. name:match(":(.*)") - output[#output + 1] = item .. " " .. count + output[i] = item .. " " .. count end inv:set_list("forms", output) @@ -184,7 +188,16 @@ function workbench.timer(pos) return true end -function workbench.put(_, listname, _, stack) +function workbench.allow_put(pos, listname, index, stack, player) + local player_name = player:get_player_name() + if ( + minetest.is_protected(pos, player_name) and + not minetest.check_player_privs(player_name, {protection_bypass=true}) + ) then + minetest.record_protection_violation(pos, player_name) + return 0 + end + local stackname = stack:get_name() if (listname == "tool" and stack:get_wear() > 0 and workbench:repairable(stackname)) or @@ -197,11 +210,13 @@ function workbench.put(_, listname, _, stack) return 0 end -function workbench.move(_, from_list, _, to_list, _, count) - return (to_list == "storage" and from_list ~= "forms") and count or 0 -end +function workbench.on_put(pos, listname, index, stack, player) + log('action', + '%s put %s in workbench at %s', + player:get_player_name(), + stack:get_name(), + minetest.pos_to_string(pos)) -function workbench.on_put(pos, listname, _, stack) local inv = minetest.get_meta(pos):get_inventory() if listname == "input" then local input = inv:get_stack("input", 1) @@ -212,7 +227,55 @@ function workbench.on_put(pos, listname, _, stack) end end +function workbench.allow_move(pos, from_list, from_index, to_list, to_index, count, player) + local player_name = player:get_player_name() + if ( + minetest.is_protected(pos, player_name) and + not minetest.check_player_privs(player_name, {protection_bypass=true}) + ) then + minetest.record_protection_violation(pos, player_name) + return 0 + end + + return (to_list == "storage" and from_list ~= "forms") and count or 0 +end + +function workbench.on_move(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local from_stack = inv:get_stack(from_list, from_index) + local to_stack = inv:get_stack(to_list, to_index) + + log('action', + '%s moved %s in workbench at %s', + player:get_player_name(), + to_stack:get_name(), + minetest.pos_to_string(pos)) + + workbench.on_take(pos, from_list, from_index, from_stack, player) + workbench.on_put(pos, to_list, to_index, to_stack, player) +end + +function workbench.allow_take(pos, listname, index, stack, player) + local player_name = player:get_player_name() + if ( + minetest.is_protected(pos, player_name) and + not minetest.check_player_privs(player_name, {protection_bypass=true}) + ) then + minetest.record_protection_violation(pos, player_name) + return 0 + end + + return stack:get_count() +end + function workbench.on_take(pos, listname, index, stack, player) + log('action', + '%s took %s from workbench at %s', + player:get_player_name(), + stack:get_name(), + minetest.pos_to_string(pos)) + local inv = minetest.get_meta(pos):get_inventory() local input = inv:get_stack("input", 1) local inputname = input:get_name() @@ -255,8 +318,10 @@ xdecor.register("workbench", { on_receive_fields = workbench.fields, on_metadata_inventory_put = workbench.on_put, on_metadata_inventory_take = workbench.on_take, - allow_metadata_inventory_put = workbench.put, - allow_metadata_inventory_move = workbench.move + on_metadata_inventory_move = workbench.on_move, + allow_metadata_inventory_put = workbench.allow_put, + allow_metadata_inventory_take = workbench.allow_take, + allow_metadata_inventory_move = workbench.allow_move }) for _, d in ipairs(workbench.defs) do From a15ce62b2089b267cad4a8d23a3e09c070d6d3ce Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Sat, 3 Aug 2019 19:38:33 +0000 Subject: [PATCH 2/7] remove unnecessary privilege checks --- src/workbench.lua | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/workbench.lua b/src/workbench.lua index 53e4712..c7a0316 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -190,10 +190,7 @@ end function workbench.allow_put(pos, listname, index, stack, player) local player_name = player:get_player_name() - if ( - minetest.is_protected(pos, player_name) and - not minetest.check_player_privs(player_name, {protection_bypass=true}) - ) then + if minetest.is_protected(pos, player_name) then minetest.record_protection_violation(pos, player_name) return 0 end @@ -229,10 +226,7 @@ end function workbench.allow_move(pos, from_list, from_index, to_list, to_index, count, player) local player_name = player:get_player_name() - if ( - minetest.is_protected(pos, player_name) and - not minetest.check_player_privs(player_name, {protection_bypass=true}) - ) then + if minetest.is_protected(pos, player_name) then minetest.record_protection_violation(pos, player_name) return 0 end @@ -258,10 +252,7 @@ end function workbench.allow_take(pos, listname, index, stack, player) local player_name = player:get_player_name() - if ( - minetest.is_protected(pos, player_name) and - not minetest.check_player_privs(player_name, {protection_bypass=true}) - ) then + if minetest.is_protected(pos, player_name) then minetest.record_protection_violation(pos, player_name) return 0 end From 1e177c009e2977c2cd50e8f8e8f2292f4698e38a Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Sun, 4 Aug 2019 22:09:02 +0000 Subject: [PATCH 3/7] remove protection checks and logging --- src/workbench.lua | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/workbench.lua b/src/workbench.lua index c7a0316..49ca30b 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -1,7 +1,3 @@ -local function log(level, message, ...) - minetest.log(level, '[xdecor] ' .. message:format(...)) -end - local workbench = {} WB = {} screwdriver = screwdriver or {} @@ -189,12 +185,6 @@ function workbench.timer(pos) end function workbench.allow_put(pos, listname, index, stack, player) - local player_name = player:get_player_name() - if minetest.is_protected(pos, player_name) then - minetest.record_protection_violation(pos, player_name) - return 0 - end - local stackname = stack:get_name() if (listname == "tool" and stack:get_wear() > 0 and workbench:repairable(stackname)) or @@ -208,12 +198,6 @@ function workbench.allow_put(pos, listname, index, stack, player) end function workbench.on_put(pos, listname, index, stack, player) - log('action', - '%s put %s in workbench at %s', - player:get_player_name(), - stack:get_name(), - minetest.pos_to_string(pos)) - local inv = minetest.get_meta(pos):get_inventory() if listname == "input" then local input = inv:get_stack("input", 1) @@ -225,12 +209,6 @@ function workbench.on_put(pos, listname, index, stack, player) end function workbench.allow_move(pos, from_list, from_index, to_list, to_index, count, player) - local player_name = player:get_player_name() - if minetest.is_protected(pos, player_name) then - minetest.record_protection_violation(pos, player_name) - return 0 - end - return (to_list == "storage" and from_list ~= "forms") and count or 0 end @@ -240,33 +218,15 @@ function workbench.on_move(pos, from_list, from_index, to_list, to_index, count, local from_stack = inv:get_stack(from_list, from_index) local to_stack = inv:get_stack(to_list, to_index) - log('action', - '%s moved %s in workbench at %s', - player:get_player_name(), - to_stack:get_name(), - minetest.pos_to_string(pos)) - workbench.on_take(pos, from_list, from_index, from_stack, player) workbench.on_put(pos, to_list, to_index, to_stack, player) end function workbench.allow_take(pos, listname, index, stack, player) - local player_name = player:get_player_name() - if minetest.is_protected(pos, player_name) then - minetest.record_protection_violation(pos, player_name) - return 0 - end - return stack:get_count() end function workbench.on_take(pos, listname, index, stack, player) - log('action', - '%s took %s from workbench at %s', - player:get_player_name(), - stack:get_name(), - minetest.pos_to_string(pos)) - local inv = minetest.get_meta(pos):get_inventory() local input = inv:get_stack("input", 1) local inputname = input:get_name() From cfca4ccdf31bb3e71db9d5ec2e255d724e66ae8e Mon Sep 17 00:00:00 2001 From: Panquesito7 <51391473+Panquesito7@users.noreply.github.com> Date: Tue, 20 Aug 2019 23:37:38 -0500 Subject: [PATCH 4/7] Update mod.conf Dependencies, optional dependencies, and description was added here. --- mod.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mod.conf b/mod.conf index 2e97596..74a8013 100644 --- a/mod.conf +++ b/mod.conf @@ -1 +1,4 @@ name = xdecor +depends = default, bucket, doors, stairs, xpanes +optional_depends = fire, oresplus, moreblocks, mesecons_plus +description = A decoration mod meant to be simple and well-featured. From 4ebdf89fcba02c6ed5a202a88d992b7a0f4c2181 Mon Sep 17 00:00:00 2001 From: Panquesito7 <51391473+Panquesito7@users.noreply.github.com> Date: Tue, 20 Aug 2019 23:39:21 -0500 Subject: [PATCH 5/7] Replace "getpos" with "get_pos" --- src/enchanting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/enchanting.lua b/src/enchanting.lua index 744dab4..aa0b301 100644 --- a/src/enchanting.lua +++ b/src/enchanting.lua @@ -237,7 +237,7 @@ minetest.register_entity("xdecor:book_open", { physical = false, textures = {"xdecor_book_open.png"}, on_activate = function(self) - local pos = self.object:getpos() + local pos = self.object:get_pos() local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z} if minetest.get_node(pos_under).name ~= "xdecor:enchantment_table" then From 39e9991404c3b516bb2c52d168bd152683055070 Mon Sep 17 00:00:00 2001 From: Panquesito7 <51391473+Panquesito7@users.noreply.github.com> Date: Tue, 20 Aug 2019 23:40:06 -0500 Subject: [PATCH 6/7] Replace "setpos" with "set_pos" --- handlers/animations.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handlers/animations.lua b/handlers/animations.lua index 6c240b4..2849667 100644 --- a/handlers/animations.lua +++ b/handlers/animations.lua @@ -18,7 +18,7 @@ function xdecor.sit(pos, node, clicker, pointed_thing) if default.player_attached[player_name] then pos.y = pos.y - 0.5 - clicker:setpos(pos) + clicker:set_pos(pos) clicker:set_eye_offset(vector.new(), vector.new()) clicker:set_physics_override({speed = 1, jump = 1, gravity = 1}) default.player_attached[player_name] = false @@ -29,7 +29,7 @@ function xdecor.sit(pos, node, clicker, pointed_thing) clicker:set_eye_offset({x = 0, y = -7, z = 2}, vector.new()) clicker:set_physics_override({speed = 0, jump = 0, gravity = 1}) - clicker:setpos(pos) + clicker:set_pos(pos) default.player_attached[player_name] = true default.player_set_animation(clicker, "sit", 30) @@ -55,4 +55,3 @@ function xdecor.sit_dig(pos, digger) return true end - From b8aaf37fc22709168b0b8776bcb1fbabc3899ac8 Mon Sep 17 00:00:00 2001 From: Niwla23 <46248939+Niwla23@users.noreply.github.com> Date: Sat, 12 Oct 2019 13:23:04 +0200 Subject: [PATCH 7/7] Display itemstring in itemframes (#116) Itemframe patch --- src/itemframe.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/itemframe.lua b/src/itemframe.lua index 0843b45..a79d56e 100644 --- a/src/itemframe.lua +++ b/src/itemframe.lua @@ -85,7 +85,11 @@ function itemframe.rightclick(pos, node, clicker, itemstack) local itemstring = itemstack:take_item():to_string() meta:set_string("item", itemstring) update_item(pos, node) - + if itemstring == "" then + meta:set_string("infotext", "Item Frame (owned by " .. owner .. ")") + else + meta:set_string("infotext", itemstring.." (owned by " .. owner .. ")") + end return itemstack end