From 14506c477ac69150fd37c80e1571e80fc0ce34fc Mon Sep 17 00:00:00 2001 From: Maciej Kasatkin Date: Wed, 12 Sep 2012 09:15:04 +0200 Subject: [PATCH] Some fixes to sonic screwdriver and gold chests --- gold_chest.lua | 165 ++++++++++++++++++++++++- sonic_screwdriver.lua | 6 +- textures/technic_sonic_screwdriver.png | Bin 2013 -> 2064 bytes 3 files changed, 165 insertions(+), 6 deletions(-) diff --git a/gold_chest.lua b/gold_chest.lua index 44fb313..401015f 100644 --- a/gold_chest.lua +++ b/gold_chest.lua @@ -1,5 +1,4 @@ local chest_mark_colors = { - '', -- regular chest, without color bar '_black', '_blue', '_brown', @@ -52,15 +51,76 @@ minetest.register_craftitem("technic:gold_locked_chest", { stack_max = 99, }) +minetest.register_node("technic:gold_chest", { + description = "Gold Chest", + tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", + "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Gold Chest") + local inv = meta:get_inventory() + inv:set_size("main", 12*4) + end, + + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + chest_punched (pos,node,puncher); + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) + for i, state in ipairs(chest_mark_colors) do minetest.register_node("technic:gold_chest".. state, { description = "Gold Chest", tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..state..".png"}, paramtype2 = "facedir", - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, not_in_creative_inventory=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), + drop = "technic:gold_chest", on_construct = function(pos) local meta = minetest.env:get_meta(pos) meta:set_string("formspec", @@ -122,13 +182,112 @@ local function has_locked_chest_privilege(meta, player) return true end +minetest.register_node("technic:gold_locked_chest", { + description = "Gold Locked Chest", + tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", + "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked.png"}, + paramtype2 = "facedir", + drop = "technic:gold_chest", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Gold Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Gold Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 12*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + local meta = minetest.env:get_meta(pos); + if (has_locked_chest_privilege(meta, puncher)) then + locked_chest_punched (pos,node,puncher); + end + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) + for i, state in ipairs(chest_mark_colors) do minetest.register_node("technic:gold_locked_chest".. state, { description = "Gold Locked Chest", tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..state..".png"}, paramtype2 = "facedir", - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + drop = "technic:gold_chest", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, not_in_creative_inventory=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) diff --git a/sonic_screwdriver.lua b/sonic_screwdriver.lua index f4e3913..07aa9b4 100644 --- a/sonic_screwdriver.lua +++ b/sonic_screwdriver.lua @@ -15,7 +15,7 @@ sonic_screwdriver_max_charge=15000 if charge ==0 then charge =65535 end charge=get_RE_item_load(charge,sonic_screwdriver_max_charge) if charge-100>0 then - minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 1.0, max_hear_distance = 10,}) + minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 0.5, max_hear_distance = 10,}) local n = node.param2 n = n+1 if n == 4 then n = 0 end @@ -40,8 +40,8 @@ sonic_screwdriver_max_charge=15000 minetest.register_craft({ output = "technic:sonic_screwdriver", recipe = { - {"technic:green_energy_crystal"}, - {"technic:stainless_steel_ingot"}, + {"technic:diamond"}, + {"technic:battery"}, {"technic:stainless_steel_ingot"} } }) diff --git a/textures/technic_sonic_screwdriver.png b/textures/technic_sonic_screwdriver.png index 59b78d4e59992cbd10ea08832fab4bf224f7c812..fb61d96190c7b4a23ba7395c816a72835c773389 100644 GIT binary patch delta 1962 zcmV;b2UYmp50DU$R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