From d998058bcda98926ad6e198dbabbcc99b9ff782a Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Wed, 21 Jun 2023 16:54:58 +0200 Subject: [PATCH] cleanup / wip --- init.lua | 1 - node.lua | 26 ++++++++++++++++++++++++-- tool.lua | 12 ++++++------ wield_check.lua | 37 ------------------------------------- 4 files changed, 30 insertions(+), 46 deletions(-) delete mode 100644 wield_check.lua diff --git a/init.lua b/init.lua index 788689c..c567b08 100644 --- a/init.lua +++ b/init.lua @@ -7,5 +7,4 @@ dofile(MP .. "/serialize.lua") dofile(MP .. "/entity.lua") dofile(MP .. "/node.lua") dofile(MP .. "/tool.lua") -dofile(MP .. "/wield_check.lua") dofile(MP .. "/preview.lua") diff --git a/node.lua b/node.lua index d240c4d..1f36ab3 100644 --- a/node.lua +++ b/node.lua @@ -1,3 +1,25 @@ --- TODO: pickup node with WE marker selection formspec --- TODO: dispense "pick_and_place:placer" tool with schematic, size and id \ No newline at end of file +minetest.register_node("pick_and_place:handle", { + description = "Pick and place handle", + tiles = {"pick_and_place_plus.png"}, + drawtype = "allfaces", + use_texture_alpha = "blend", + paramtype = "light", + sunlight_propagates = true, + groups = { + oddly_breakable_by_hand = 3 + } +}) + +minetest.register_node("pick_and_place:handle_configured", { + description = "Pick and place handle (configured)", + tiles = {"pick_and_place_plus.png^[colorize:#00ff00"}, + drawtype = "allfaces", + use_texture_alpha = "blend", + paramtype = "light", + sunlight_propagates = true, + groups = { + oddly_breakable_by_hand = 3, + not_in_creative_inventory = 1 + } +}) \ No newline at end of file diff --git a/tool.lua b/tool.lua index 0a7f027..1355e26 100644 --- a/tool.lua +++ b/tool.lua @@ -6,10 +6,10 @@ minetest.register_tool("pick_and_place:placer", { range = 0, on_use = function(itemstack, player) end, + on_focus = function(itemstack, player) + end, + on_step = function(itemstack, player) + end, + on_blur = function(player) + end }) - -function pick_and_place.on_step() -end - -function pick_and_place.on_blur() -end diff --git a/wield_check.lua b/wield_check.lua deleted file mode 100644 index c490bfe..0000000 --- a/wield_check.lua +++ /dev/null @@ -1,37 +0,0 @@ --- playername -> name -local last_wielded_item = {} - --- check for tools -local function wield_check() - for _, player in ipairs(minetest.get_connected_players()) do - local itemstack = player:get_wielded_item() - local playername = player:get_player_name() - local id, name - if itemstack then - name = itemstack:get_name() - local meta = itemstack:get_meta() - id = meta:get_int("id") - end - local is_placer = name == "pick_and_place:placer" - - if last_wielded_item[playername] and name ~= last_wielded_item[playername] then - -- last item got out of focus - local item_def = minetest.registered_items[last_wielded_item[playername]] - if item_def and type(item_def.on_blur) == "function" then - item_def.on_blur(player) - end - end - - if is_placer then - pick_and_place.on_step(itemstack, player) - end - - last_wielded_item[playername] = name - end - minetest.after(0, wield_check) -end - -minetest.after(0, wield_check) -minetest.register_on_leaveplayer(function(player) - last_wielded_item[player:get_player_name()] = nil -end) \ No newline at end of file