Add support for minetest.swap_node

This commit is contained in:
ShadowNinja 2013-12-10 20:14:39 -05:00
parent 818a0e5ff0
commit f3d8b47b20
19 changed files with 71 additions and 71 deletions

@ -8,3 +8,27 @@ end
function set_item_meta (table) function set_item_meta (table)
return minetest.serialize(table) return minetest.serialize(table)
end end
function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
minetest.swap_node = minetest.swap_node or function(pos, node)
local oldmeta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, node)
minetest.get_meta(pos):from_table(oldmeta)
end
-- Only changes name, keeps other params
function technic.swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name ~= name then
node.name = name
minetest.swap_node(pos, node)
end
return node.name
end

@ -40,27 +40,6 @@ dofile(modpath.."/tools/init.lua")
-- Aliases for legacy node/item names -- Aliases for legacy node/item names
dofile(modpath.."/legacy.lua") dofile(modpath.."/legacy.lua")
function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
-- Swap nodes out. Return the node name.
function hacky_swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name ~= name then
local meta = minetest.get_meta(pos)
local meta_table = meta:to_table()
node.name = name
minetest.set_node(pos, node)
meta = minetest.get_meta(pos)
meta:from_table(meta_table)
end
return node.name
end
if minetest.setting_get("log_mod") then if minetest.setting_get("log_mod") then
print(S("[Technic] Loaded in %f seconds"):format(os.clock() - load_start)) print(S("[Technic] Loaded in %f seconds"):format(os.clock() - load_start))
end end

@ -178,7 +178,7 @@ minetest.register_abm({
if node.name == "technic:forcefield_emitter_on" then if node.name == "technic:forcefield_emitter_on" then
meta:set_int("HV_EU_demand", 0) meta:set_int("HV_EU_demand", 0)
update_forcefield(pos, meta:get_int("range"), false) update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off") technic.swap_node(pos, "technic:forcefield_emitter_off")
meta:set_string("infotext", S("%s Disabled"):format(machine_name)) meta:set_string("infotext", S("%s Disabled"):format(machine_name))
return return
end end
@ -186,11 +186,11 @@ minetest.register_abm({
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
if node.name == "technic:forcefield_emitter_on" then if node.name == "technic:forcefield_emitter_on" then
update_forcefield(pos, meta:get_int("range"), false) update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off") technic.swap_node(pos, "technic:forcefield_emitter_off")
end end
elseif eu_input >= power_requirement then elseif eu_input >= power_requirement then
if node.name == "technic:forcefield_emitter_off" then if node.name == "technic:forcefield_emitter_off" then
hacky_swap_node(pos, "technic:forcefield_emitter_on") technic.swap_node(pos, "technic:forcefield_emitter_on")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
end end
update_forcefield(pos, meta:get_int("range"), true) update_forcefield(pos, meta:get_int("range"), true)

@ -214,7 +214,7 @@ minetest.register_abm({
if correct_fuel_count == 6 and if correct_fuel_count == 6 and
check_reactor_structure(pos) then check_reactor_structure(pos) then
meta:set_int("burn_time", 1) meta:set_int("burn_time", 1)
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core_active") technic.swap_node(pos, "technic:hv_nuclear_reactor_core_active")
meta:set_int("HV_EU_supply", power_supply) meta:set_int("HV_EU_supply", power_supply)
for idx, srcstack in pairs(srclist) do for idx, srcstack in pairs(srclist) do
srcstack:take_item() srcstack:take_item()
@ -226,7 +226,7 @@ minetest.register_abm({
meta:set_int("HV_EU_supply", 0) meta:set_int("HV_EU_supply", 0)
meta:set_int("burn_time", 0) meta:set_int("burn_time", 0)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core") technic.swap_node(pos, "technic:hv_nuclear_reactor_core")
elseif burn_time > 0 then elseif burn_time > 0 then
damage_nearby_players(pos) damage_nearby_players(pos)
if not check_reactor_structure(pos) then if not check_reactor_structure(pos) then

@ -200,17 +200,17 @@ minetest.register_abm({
if inv:is_empty("src") or if inv:is_empty("src") or
(not minetest.registered_nodes[result]) or (not minetest.registered_nodes[result]) or
(not inv:room_for_item("dst", result)) then (not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
meta:set_string("cnc_product", "") meta:set_string("cnc_product", "")
return return
end end
if eu_input < demand then if eu_input < demand then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= demand then elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 3 then -- 3 ticks per output if meta:get_int("src_time") >= 3 then -- 3 ticks per output

@ -121,7 +121,7 @@ minetest.register_abm({
local percent = math.floor(meta:get_float("fuel_time") / local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100) meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)") meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
hacky_swap_node(pos, "technic:coal_alloy_furnace_active") technic.swap_node(pos, "technic:coal_alloy_furnace_active")
meta:set_string("formspec", meta:set_string("formspec",
"size[8,9]".. "size[8,9]"..
"label[0,0;"..machine_name.."]".. "label[0,0;"..machine_name.."]"..
@ -144,7 +144,7 @@ minetest.register_abm({
if recipe then if recipe then
if was_active then if was_active then
meta:set_string("infotext", "Furnace is empty") meta:set_string("infotext", "Furnace is empty")
hacky_swap_node(pos, "technic:coal_alloy_furnace") technic.swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec) meta:set_string("formspec", formspec)
end end
return return
@ -160,7 +160,7 @@ minetest.register_abm({
if fuel.time <= 0 then if fuel.time <= 0 then
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name)) meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
hacky_swap_node(pos, "technic:coal_alloy_furnace") technic.swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec) meta:set_string("formspec", formspec)
return return
end end

@ -125,7 +125,7 @@ minetest.register_abm({
end end
if empty or (not result) or if empty or (not result) or
(not inv:room_for_item("dst", result)) then (not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
meta:set_int("LV_EU_demand", 0) meta:set_int("LV_EU_demand", 0)
meta:set_int("src_time", 0) meta:set_int("src_time", 0)
@ -133,10 +133,10 @@ minetest.register_abm({
end end
if eu_input < demand then if eu_input < demand then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= demand then elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)

@ -132,7 +132,7 @@ minetest.register_abm({
end end
if inv:is_empty("src") or (not recipe) or (not result) or if inv:is_empty("src") or (not recipe) or (not result) or
(not inv:room_for_item("dst", result)) then (not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
meta:set_int("LV_EU_demand", 0) meta:set_int("LV_EU_demand", 0)
return return
@ -140,11 +140,11 @@ minetest.register_abm({
if eu_input < demand then if eu_input < demand then
-- unpowered - go idle -- unpowered - go idle
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= demand then elseif eu_input >= demand then
-- Powered -- Powered
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)

@ -99,11 +99,11 @@ minetest.register_abm({
S("Geothermal Generator").." ("..production_level.."%)") S("Geothermal Generator").." ("..production_level.."%)")
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then
hacky_swap_node (pos, "technic:geothermal_active") technic.swap_node (pos, "technic:geothermal_active")
return return
end end
if production_level == 0 then if production_level == 0 then
hacky_swap_node(pos, "technic:geothermal") technic.swap_node(pos, "technic:geothermal")
meta:set_int("LV_EU_supply", 0) meta:set_int("LV_EU_supply", 0)
end end
end end

@ -89,12 +89,12 @@ minetest.register_abm({
if production_level > 0 and if production_level > 0 and
minetest.get_node(pos).name == "technic:water_mill" then minetest.get_node(pos).name == "technic:water_mill" then
hacky_swap_node (pos, "technic:water_mill_active") technic.swap_node (pos, "technic:water_mill_active")
meta:set_int("LV_EU_supply", 0) meta:set_int("LV_EU_supply", 0)
return return
end end
if production_level == 0 then if production_level == 0 then
hacky_swap_node(pos, "technic:water_mill") technic.swap_node(pos, "technic:water_mill")
end end
end end
}) })

@ -43,7 +43,7 @@ end
technic.inductive_on_punch_off = function(pos, eu_charge, swapnode) technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("has_supply") ~= "" then if meta:get_string("has_supply") ~= "" then
hacky_swap_node(pos, swapnode) technic.swap_node(pos, swapnode)
meta:set_int("active", 1) meta:set_int("active", 1)
meta:set_int("EU_charge",eu_charge) meta:set_int("EU_charge",eu_charge)
--print("-----------") --print("-----------")
@ -56,7 +56,7 @@ end
technic.inductive_on_punch_on = function(pos, eu_charge, swapnode) technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
hacky_swap_node(pos, swapnode) technic.swap_node(pos, swapnode)
meta:set_int("active", 0) meta:set_int("active", 0)
meta:set_int("EU_charge",eu_charge) meta:set_int("EU_charge",eu_charge)
--print("-----------") --print("-----------")
@ -82,7 +82,7 @@ local shutdown_inductive_appliances = function(pos)
local nodename = minetest.get_node(pos1).name local nodename = minetest.get_node(pos1).name
-- Swap the node and make sure it is off and unpowered -- Swap the node and make sure it is off and unpowered
if string.sub(nodename, -7) == "_active" then if string.sub(nodename, -7) == "_active" then
hacky_swap_node(pos1, string.sub(nodename, 1, -8)) technic.swap_node(pos1, string.sub(nodename, 1, -8))
meta1:set_int("active", 0) meta1:set_int("active", 0)
meta1:set_int("EU_charge", 0) meta1:set_int("EU_charge", 0)
end end

@ -34,7 +34,7 @@ mk1_on = function(pos, node)
if node.param2==0 then pos1.z=pos1.z-1 end if node.param2==0 then pos1.z=pos1.z-1 end
if node.name == "technic:constructor_mk1_off" then if node.name == "technic:constructor_mk1_off" then
hacky_swap_node(pos,"technic:constructor_mk1_on") technic.swap_node(pos,"technic:constructor_mk1_on")
nodeupdate(pos) nodeupdate(pos)
local node1=minetest.get_node(pos1) local node1=minetest.get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node) deploy_node (inv,"slot1",pos1,node1,node)
@ -43,7 +43,7 @@ end
mk1_off = function(pos, node) mk1_off = function(pos, node)
if node.name == "technic:constructor_mk1_on" then if node.name == "technic:constructor_mk1_on" then
hacky_swap_node(pos,"technic:constructor_mk1_off") technic.swap_node(pos,"technic:constructor_mk1_off")
nodeupdate(pos) nodeupdate(pos)
end end
end end
@ -114,7 +114,7 @@ mk2_on = function(pos, node)
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
if node.name == "technic:constructor_mk2_off" then if node.name == "technic:constructor_mk2_off" then
hacky_swap_node(pos,"technic:constructor_mk2_on") technic.swap_node(pos,"technic:constructor_mk2_on")
nodeupdate(pos) nodeupdate(pos)
local node1=minetest.get_node(pos1) local node1=minetest.get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node) deploy_node (inv,"slot1",pos1,node1,node)
@ -125,7 +125,7 @@ end
mk2_off = function(pos, node) mk2_off = function(pos, node)
if node.name == "technic:constructor_mk2_on" then if node.name == "technic:constructor_mk2_on" then
hacky_swap_node(pos,"technic:constructor_mk2_off") technic.swap_node(pos,"technic:constructor_mk2_off")
nodeupdate(pos) nodeupdate(pos)
end end
end end
@ -212,7 +212,7 @@ mk3_on = function(pos, node)
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
if node.name == "technic:constructor_mk3_off" then if node.name == "technic:constructor_mk3_off" then
hacky_swap_node(pos,"technic:constructor_mk3_on") technic.swap_node(pos,"technic:constructor_mk3_on")
nodeupdate(pos) nodeupdate(pos)
local node1=minetest.get_node(pos1) local node1=minetest.get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node) deploy_node (inv,"slot1",pos1,node1,node)
@ -227,7 +227,7 @@ end
mk3_off = function(pos, node) mk3_off = function(pos, node)
if node.name == "technic:constructor_mk3_on" then if node.name == "technic:constructor_mk3_on" then
hacky_swap_node(pos,"technic:constructor_mk3_off") technic.swap_node(pos,"technic:constructor_mk3_off")
nodeupdate(pos) nodeupdate(pos)
end end
end end

@ -342,7 +342,7 @@ local function swap_template(pos, new)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local saved_node = meta:get_string("saved_node") local saved_node = meta:get_string("saved_node")
meta:set_string("saved_node", "") meta:set_string("saved_node", "")
hacky_swap_node(pos, new) technic.swap_node(pos, new)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("saved_node", saved_node) meta:set_string("saved_node", saved_node)
end end

@ -205,7 +205,7 @@ function technic.register_alloy_furnace(data)
end end
if not result or if not result or
not inv:room_for_item("dst", result) then not inv:room_for_item("dst", result) then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
meta:set_int(tier.."_EU_demand", 0) meta:set_int(tier.."_EU_demand", 0)
return return
@ -213,11 +213,11 @@ function technic.register_alloy_furnace(data)
if eu_input < machine_demand[EU_upgrade+1] then if eu_input < machine_demand[EU_upgrade+1] then
-- Unpowered - go idle -- Unpowered - go idle
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= machine_demand[EU_upgrade+1] then elseif eu_input >= machine_demand[EU_upgrade+1] then
-- Powered -- Powered
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == data.cook_time then if meta:get_int("src_time") == data.cook_time then

@ -126,7 +126,7 @@ function technic.register_battery_box(data)
charge_count = math.max(charge_count, 0) charge_count = math.max(charge_count, 0)
local last_count = meta:get_float("last_side_shown") local last_count = meta:get_float("last_side_shown")
if charge_count ~= last_count then if charge_count ~= last_count then
hacky_swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count) technic.swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count)
meta:set_float("last_side_shown", charge_count) meta:set_float("last_side_shown", charge_count)
end end

@ -142,18 +142,18 @@ function technic.register_electric_furnace(data)
if not result or result.time == 0 or if not result or result.time == 0 or
not inv:room_for_item("dst", result.item) then not inv:room_for_item("dst", result.item) then
meta:set_int(tier.."_EU_demand", 0) meta:set_int(tier.."_EU_demand", 0)
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
return return
end end
if eu_input < machine_demand[EU_upgrade+1] then if eu_input < machine_demand[EU_upgrade+1] then
-- Unpowered - go idle -- Unpowered - go idle
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= machine_demand[EU_upgrade+1] then elseif eu_input >= machine_demand[EU_upgrade+1] then
-- Powered -- Powered
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
technic.smelt_item(meta, result, data.speed) technic.smelt_item(meta, result, data.speed)

@ -99,7 +99,7 @@ function technic.register_generator(data)
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if not fuel or fuel.time == 0 then if not fuel or fuel.time == 0 then
meta:set_string("infotext", S("%s Out Of Fuel"):format(desc)) meta:set_string("infotext", S("%s Out Of Fuel"):format(desc))
hacky_swap_node(pos, "technic:"..ltier.."_generator") technic.swap_node(pos, "technic:"..ltier.."_generator")
return return
end end
meta:set_int("burn_time", fuel.time) meta:set_int("burn_time", fuel.time)
@ -107,10 +107,10 @@ function technic.register_generator(data)
local stack = inv:get_stack("src", 1) local stack = inv:get_stack("src", 1)
stack:take_item() stack:take_item()
inv:set_stack("src", 1, stack) inv:set_stack("src", 1, stack)
hacky_swap_node(pos, "technic:"..ltier.."_generator_active") technic.swap_node(pos, "technic:"..ltier.."_generator_active")
meta:set_int(tier.."_EU_supply", data.supply) meta:set_int(tier.."_EU_supply", data.supply)
else else
hacky_swap_node(pos, "technic:"..ltier.."_generator") technic.swap_node(pos, "technic:"..ltier.."_generator")
meta:set_int(tier.."_EU_supply", 0) meta:set_int(tier.."_EU_supply", 0)
end end
end end

@ -120,7 +120,7 @@ function technic.register_grinder(data)
local result = technic.get_grinder_recipe(inv:get_stack("src", 1)) local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
if not result then if not result then
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("%s Idle"):format(machine_name))
meta:set_int(tier.."_EU_demand", 0) meta:set_int(tier.."_EU_demand", 0)
return return
@ -128,11 +128,11 @@ function technic.register_grinder(data)
if eu_input < machine_demand[EU_upgrade+1] then if eu_input < machine_demand[EU_upgrade+1] then
-- Unpowered - go idle -- Unpowered - go idle
hacky_swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= machine_demand[EU_upgrade+1] then elseif eu_input >= machine_demand[EU_upgrade+1] then
-- Powered -- Powered
hacky_swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)

@ -44,12 +44,8 @@ minetest.register_tool("technic:sonic_screwdriver", {
if minetest.is_protected(pos, user:get_player_name()) then if minetest.is_protected(pos, user:get_player_name()) then
minetest.record_protection_violation(pos, user:get_player_name()) minetest.record_protection_violation(pos, user:get_player_name())
else else
local meta = minetest.get_meta(pos)
local meta0 = meta:to_table()
node.param2 = p node.param2 = p
minetest.set_node(pos, node) minetest.swap_node(pos, node)
meta = minetest.get_meta(pos)
meta:from_table(meta0)
meta1.charge = meta1.charge - 100 meta1.charge = meta1.charge - 100
itemstack:set_metadata(set_item_meta(meta1)) itemstack:set_metadata(set_item_meta(meta1))
@ -68,3 +64,4 @@ minetest.register_craft({
{"technic:stainless_steel_ingot"} {"technic:stainless_steel_ingot"}
} }
}) })