technic/helpers.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/MV/init.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/other/constructor.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/other/frames.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/other/injector.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/register/alloy_furnace.lua | ●●●●● patch | view | raw | blame | history | |
technic/machines/register/battery_box.lua | ●●●●● patch | view | raw | blame | history | |
technic/tools/chainsaw.lua | ●●●●● patch | view | raw | blame | history | |
technic/tools/flashlight.lua | ●●●●● patch | view | raw | blame | history | |
technic/tools/mining_drill.lua | ●●●●● patch | view | raw | blame | history | |
technic/tools/mining_lasers.lua | ●●●●● patch | view | raw | blame | history | |
technic/tools/sonic_screwdriver.lua | ●●●●● patch | view | raw | blame | history |
technic/helpers.lua
@@ -1,21 +1,3 @@ function get_item_meta (string) if string.find(string, "return {") then return minetest.deserialize(string) else return nil end end function set_item_meta (table) return minetest.serialize(table) 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) technic/machines/MV/init.lua
@@ -17,6 +17,7 @@ -- The power radiator supplies appliances with inductive coupled power: -- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric. dofile(path.."/power_radiator.lua") dofile(path.."/lighting.lua") -- This is currently useless, slow, and mostly copied --dofile(path.."/power_radiator.lua") --dofile(path.."/lighting.lua") technic/machines/other/constructor.lua
@@ -21,7 +21,7 @@ }) mk1_on = function(pos, node) local function mk1_on(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local pos1={} @@ -41,7 +41,7 @@ end end mk1_off = function(pos, node) local function mk1_off(pos, node) if node.name == "technic:constructor_mk1_on" then technic.swap_node(pos,"technic:constructor_mk1_off") nodeupdate(pos) @@ -97,7 +97,7 @@ --Constructor Mk2 mk2_on = function(pos, node) local function mk2_on(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local pos1={} @@ -123,7 +123,7 @@ end end mk2_off = function(pos, node) local function mk2_off(pos, node) if node.name == "technic:constructor_mk2_on" then technic.swap_node(pos,"technic:constructor_mk2_off") nodeupdate(pos) @@ -181,7 +181,7 @@ -- Constructor Mk3 mk3_on = function(pos, node) local function mk3_on(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -225,7 +225,7 @@ end end mk3_off = function(pos, node) local function mk3_off(pos, node) if node.name == "technic:constructor_mk3_on" then technic.swap_node(pos,"technic:constructor_mk3_off") nodeupdate(pos) @@ -289,7 +289,7 @@ }) deploy_node =function (inv, slot_name, pos1, node1, node) local function deploy_node(inv, slot_name, pos1, node1, node) if node1.name == "air" then if not inv:is_empty(slot_name) then stack1=inv:get_list(slot_name) technic/machines/other/frames.lua
@@ -43,7 +43,7 @@ end end function lines(str) local function lines(str) local t = {} local function helper(line) table.insert(t, line) return "" end helper((str:gsub("(.-)\r?\n", helper))) technic/machines/other/injector.lua
@@ -74,7 +74,7 @@ end, }) function inject_items (pos) local function inject_items (pos) local meta=minetest.env:get_meta(pos) local inv = meta:get_inventory() local mode=meta:get_string("mode") technic/machines/register/alloy_furnace.lua
@@ -6,11 +6,11 @@ -- Register recipe in a table technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3) in1 = { local in1 = { name = metal1, count = count1, } in2 = { local in2 = { name = metal2, count = count2, } technic/machines/register/battery_box.lua
@@ -161,14 +161,14 @@ return batt_charge end local srcstack = inv:get_stack("src", 1) local src_meta = get_item_meta(srcstack:get_metadata()) local src_meta = minetest.deserialize(srcstack:get_metadata()) local toolname = srcstack:get_name() if not technic.power_tools[toolname] then return batt_charge end -- Set meta data for the tool if it didn't do it itself src_meta = get_item_meta(srcstack:get_metadata()) src_meta = minetest.deserialize(srcstack:get_metadata()) src_meta = src_meta or {} if not src_meta.charge then src_meta.charge = 0 @@ -185,7 +185,7 @@ batt_charge = batt_charge - charge_step technic.set_RE_wear(srcstack, tool_charge, item_max_charge) src_meta.charge = tool_charge srcstack:set_metadata(set_item_meta(src_meta)) srcstack:set_metadata(minetest.serialize(src_meta)) inv:set_stack("src", 1, srcstack) return batt_charge end @@ -202,7 +202,7 @@ return batt_charge end -- Set meta data for the tool if it didn't do it itself :-( local src_meta = get_item_meta(srcstack:get_metadata()) local src_meta = minetest.deserialize(srcstack:get_metadata()) src_meta = src_meta or {} if not src_meta.charge then src_meta.charge = 0 @@ -220,7 +220,7 @@ batt_charge = batt_charge + charge_step technic.set_RE_wear(srcstack, tool_charge, item_max_charge) src_meta.charge = tool_charge srcstack:set_metadata(set_item_meta(src_meta)) srcstack:set_metadata(minetest.serialize(src_meta)) inv:set_stack("dst", 1, srcstack) return batt_charge end technic/tools/chainsaw.lua
@@ -3,44 +3,6 @@ local chainsaw_charge_per_node = 12 -- 12 - Gives 2500 nodes on a single charge (about 50 complete normal trees) local chainsaw_leaves = true -- true - Cut down entire trees, leaves and all local S = technic.getter technic.register_power_tool("technic:chainsaw", chainsaw_max_charge) minetest.register_tool("technic:chainsaw", { description = S("Chainsaw"), inventory_image = "technic_chainsaw.png", stack_max = 1, on_use = function(itemstack, user, pointed_thing) if pointed_thing.type ~= "node" then return itemstack end local meta = get_item_meta(itemstack:get_metadata()) if not meta or not meta.charge then return end -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes. if meta.charge < chainsaw_charge_per_node then return end local pos = minetest.get_pointed_thing_position(pointed_thing, above) meta.charge = chainsaw_dig_it(pos, user, meta.charge) technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge) itemstack:set_metadata(set_item_meta(meta)) return itemstack end, }) minetest.register_craft({ output = 'technic:chainsaw', recipe = { {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'}, {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'}, {'', '', 'default:copper_ingot'}, } }) -- The default stuff local timber_nodenames={["default:jungletree"] = true, ["default:papyrus"] = true, @@ -155,55 +117,17 @@ end end local S = technic.getter technic.register_power_tool("technic:chainsaw", chainsaw_max_charge) -- Table for saving what was sawed down local produced -- Saw down trees entry point chainsaw_dig_it = function(pos, player,current_charge) local remaining_charge=current_charge -- Save the currently installed dropping mechanism so we can restore it. local original_handle_node_drops = minetest.handle_node_drops -- A bit of trickery here: use a different node drop callback -- and restore the original afterwards. minetest.handle_node_drops = chainsaw_handle_node_drops -- clear result and start sawing things down produced = {} remaining_charge = recursive_dig(pos, remaining_charge, player) minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,}) -- Restore the original noder drop handler minetest.handle_node_drops = original_handle_node_drops -- Now drop items for the player local number, produced_item, p for produced_item,number in pairs(produced) do --print("ADDING ITEM: " .. produced_item .. " " .. number) -- Drop stacks of 99 or less p = { x = pos.x + math.random()*4, y = pos.y, z = pos.z + math.random()*4 } while number > 99 do minetest.env:add_item(p, produced_item .. " 99") p = { x = pos.x + math.random()*4, y = pos.y, z = pos.z + math.random()*4 } number = number - 99 end minetest.env:add_item(p, produced_item .. " " .. number) end return remaining_charge end local produced = nil -- Override the default handling routine to be able to count up the -- items sawed down so that we can drop them i an nice single stack chainsaw_handle_node_drops = function(pos, drops, digger) local function chainsaw_handle_node_drops(pos, drops, digger) -- Add dropped items to list of collected nodes local _, dropped_item for _, dropped_item in ipairs(drops) do @@ -217,7 +141,7 @@ -- This function does all the hard work. Recursively we dig the node at hand -- if it is in the table and then search the surroundings for more stuff to dig. recursive_dig = function(pos, remaining_charge, player) local function recursive_dig(pos, remaining_charge, player) local node=minetest.env:get_node(pos) local i=1 -- Lookup node name in timber table: @@ -277,3 +201,81 @@ return remaining_charge end -- Saw down trees entry point local function chainsaw_dig_it(pos, player,current_charge) local remaining_charge=current_charge -- Save the currently installed dropping mechanism so we can restore it. local original_handle_node_drops = minetest.handle_node_drops -- A bit of trickery here: use a different node drop callback -- and restore the original afterwards. minetest.handle_node_drops = chainsaw_handle_node_drops -- clear result and start sawing things down produced = {} remaining_charge = recursive_dig(pos, remaining_charge, player) minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,}) -- Restore the original noder drop handler minetest.handle_node_drops = original_handle_node_drops -- Now drop items for the player local number, produced_item, p for produced_item,number in pairs(produced) do --print("ADDING ITEM: " .. produced_item .. " " .. number) -- Drop stacks of 99 or less p = { x = pos.x + math.random()*4, y = pos.y, z = pos.z + math.random()*4 } while number > 99 do minetest.env:add_item(p, produced_item .. " 99") p = { x = pos.x + math.random()*4, y = pos.y, z = pos.z + math.random()*4 } number = number - 99 end minetest.env:add_item(p, produced_item .. " " .. number) end return remaining_charge end minetest.register_tool("technic:chainsaw", { description = S("Chainsaw"), inventory_image = "technic_chainsaw.png", stack_max = 1, on_use = function(itemstack, user, pointed_thing) if pointed_thing.type ~= "node" then return itemstack end local meta = minetest.deserialize(itemstack:get_metadata()) if not meta or not meta.charge then return end -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes. if meta.charge < chainsaw_charge_per_node then return end local pos = minetest.get_pointed_thing_position(pointed_thing, above) meta.charge = chainsaw_dig_it(pos, user, meta.charge) technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge) itemstack:set_metadata(minetest.serialize(meta)) return itemstack end, }) minetest.register_craft({ output = 'technic:chainsaw', recipe = { {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'}, {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'}, {'', '', 'default:copper_ingot'}, } }) technic/tools/flashlight.lua
@@ -151,14 +151,14 @@ local hotbar = inv:get_list("main") for i = 1, 8 do if hotbar[i]:get_name() == "technic:flashlight" then local meta = get_item_meta(hotbar[i]:get_metadata()) local meta = minetest.deserialize(hotbar[i]:get_metadata()) if not meta or not meta.charge then return false end if meta.charge - 2 > 0 then meta.charge = meta.charge - 2; technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge) hotbar[i]:set_metadata(set_item_meta(meta)) hotbar[i]:set_metadata(minetest.serialize(meta)) inv:set_stack("main", i, hotbar[i]) return true end technic/tools/mining_drill.lua
@@ -42,7 +42,102 @@ }) end function drill_dig_it(pos, player, drill_type, mode) local mining_drill_mode_text = { {S("Single node.")}, {S("3 nodes deep.")}, {S("3 nodes wide.")}, {S("3 nodes tall.")}, {S("3x3 nodes.")}, } local function drill_dig_it0 (pos,player) local node=minetest.env:get_node(pos) if node.name == "air" or node.name == "ignore" then return end if node.name == "default:lava_source" then return end if node.name == "default:lava_flowing" then return end if node.name == "default:water_source" then minetest.env:remove_node(pos) return end if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end minetest.node_dig(pos,node,player) end local function drill_dig_it1 (player) local dir=player:get_look_dir() if math.abs(dir.x)>math.abs(dir.z) then if dir.x>0 then return 0 end return 1 end if dir.z>0 then return 2 end return 3 end local function drill_dig_it2 (pos,player) drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 pos.y=pos.y+1 drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 pos.y=pos.y-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) end local function drill_dig_it3 (pos,player) drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.y=pos.y+1 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.y=pos.y-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) end local function drill_dig_it4 (pos,player) drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) end local function drill_dig_it(pos, player, drill_type, mode) local charge if mode == 1 then drill_dig_it0(pos, player) @@ -100,9 +195,9 @@ if mode==4 then -- 3 tall, selected in the middle drill_dig_it0 (pos,player) pos.y=pos.y+1 pos.y=pos.y-1 drill_dig_it0 (pos,player) pos.y=pos.y-2 pos.y=pos.y-1 drill_dig_it0 (pos,player) end @@ -135,92 +230,99 @@ return charge end function drill_dig_it0 (pos,player) local node=minetest.env:get_node(pos) if node.name == "air" or node.name == "ignore" then return end if node.name == "default:lava_source" then return end if node.name == "default:lava_flowing" then return end if node.name == "default:water_source" then minetest.env:remove_node(pos) return end if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end minetest.node_dig(pos,node,player) end function drill_dig_it1 (player) local dir=player:get_look_dir() if math.abs(dir.x)>math.abs(dir.z) then if dir.x>0 then return 0 end return 1 local function mining_drill_mk2_setmode(user,itemstack) local player_name=user:get_player_name() local item=itemstack:to_table() local meta=minetest.deserialize(item["metadata"]) if meta==nil then meta={} mode=0 end if dir.z>0 then return 2 end return 3 if meta["mode"]==nil then minetest.chat_send_player(player_name, S("Hold shift and use to change Mining Drill Mk%d modes."):format(2)) meta["mode"]=0 mode=0 end mode=(meta["mode"]) mode=mode+1 if mode>=5 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(2, mode)..": "..mining_drill_mode_text[mode][1]) item["name"]="technic:mining_drill_mk2_"..mode meta["mode"]=mode item["metadata"]=minetest.serialize(meta) itemstack:replace(item) return itemstack end function drill_dig_it2 (pos,player) drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 pos.y=pos.y+1 drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 pos.y=pos.y-2 drill_dig_it0 (pos,player) pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.z=pos.z-2 drill_dig_it0 (pos,player) end function drill_dig_it3 (pos,player) drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.y=pos.y+1 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.y=pos.y-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) local function mining_drill_mk3_setmode(user,itemstack) local player_name=user:get_player_name() local item=itemstack:to_table() local meta=minetest.deserialize(item["metadata"]) if meta==nil then meta={} mode=0 end if meta["mode"]==nil then minetest.chat_send_player(player_name, S("Hold shift and use to change Mining Drill Mk%d modes."):format(3)) meta["mode"]=0 mode=0 end mode=(meta["mode"]) mode=mode+1 if mode>=6 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(3, mode)..": "..mining_drill_mode_text[mode][1]) item["name"]="technic:mining_drill_mk3_"..mode meta["mode"]=mode item["metadata"]=minetest.serialize(meta) itemstack:replace(item) return itemstack end function drill_dig_it4 (pos,player) drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.z=pos.z+1 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 pos.z=pos.z-2 drill_dig_it0 (pos,player) pos.x=pos.x+1 drill_dig_it0 (pos,player) pos.x=pos.x-2 drill_dig_it0 (pos,player) local function mining_drill_mk2_handler(itemstack, user, pointed_thing) local keys = user:get_player_control() local player_name = user:get_player_name() local meta = minetest.deserialize(itemstack:get_metadata()) if not meta or not meta.mode or keys.sneak then return mining_drill_mk2_setmode(user, itemstack) end if pointed_thing.type ~= "node" or not meta.charge then return end if meta.charge - mining_drill_power_usage > 0 then local pos = minetest.get_pointed_thing_position(pointed_thing, above) local charge_to_take = drill_dig_it(pos, user, 2, meta.mode) meta.charge = meta.charge - charge_to_take meta.charge = math.max(meta.charge, 0) itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk2_max_charge) end return itemstack end local function mining_drill_mk3_handler(itemstack, user, pointed_thing) local keys = user:get_player_control() local player_name = user:get_player_name() local meta = minetest.deserialize(itemstack:get_metadata()) if not meta or not meta.mode or keys.sneak then return mining_drill_mk3_setmode(user, itemstack) end if pointed_thing.type ~= "node" or not meta.charge then return end if meta.charge - mining_drill_power_usage > 0 then local pos = minetest.get_pointed_thing_position(pointed_thing, above) local charge_to_take = drill_dig_it(pos, user, 3, meta.mode) meta.charge = meta.charge - charge_to_take meta.charge = math.max(meta.charge, 0) itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk3_max_charge) end return itemstack end technic.register_power_tool("technic:mining_drill", mining_drill_max_charge) minetest.register_tool("technic:mining_drill", { description = S("Mining Drill Mk%d"):format(1), inventory_image = "technic_mining_drill.png", @@ -229,7 +331,7 @@ if pointed_thing.type ~= "node" then return itemstack end local meta = get_item_meta(itemstack:get_metadata()) local meta = minetest.deserialize(itemstack:get_metadata()) if not meta or not meta.charge then return end @@ -237,7 +339,7 @@ local pos = minetest.get_pointed_thing_position(pointed_thing, above) charge_to_take = drill_dig_it(pos, user, 1, 1) meta.charge = meta.charge - mining_drill_power_usage itemstack:set_metadata(set_item_meta(meta)) itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, meta.charge, mining_drill_max_charge) end return itemstack @@ -293,102 +395,3 @@ end, }) end function mining_drill_mk2_handler(itemstack, user, pointed_thing) local keys = user:get_player_control() local player_name = user:get_player_name() local meta = get_item_meta(itemstack:get_metadata()) if not meta or not meta.mode or keys.sneak then return mining_drill_mk2_setmode(user, itemstack) end if pointed_thing.type ~= "node" or not meta.charge then return end if meta.charge - mining_drill_power_usage > 0 then local pos = minetest.get_pointed_thing_position(pointed_thing, above) local charge_to_take = drill_dig_it(pos, user, 2, meta.mode) meta.charge = meta.charge - charge_to_take meta.charge = math.max(meta.charge, 0) itemstack:set_metadata(set_item_meta(meta)) technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk2_max_charge) end return itemstack end function mining_drill_mk3_handler(itemstack, user, pointed_thing) local keys = user:get_player_control() local player_name = user:get_player_name() local meta = get_item_meta(itemstack:get_metadata()) if not meta or not meta.mode or keys.sneak then return mining_drill_mk3_setmode(user, itemstack) end if pointed_thing.type ~= "node" or not meta.charge then return end if meta.charge - mining_drill_power_usage > 0 then local pos = minetest.get_pointed_thing_position(pointed_thing, above) local charge_to_take = drill_dig_it(pos, user, 3, meta.mode) meta.charge = meta.charge - charge_to_take meta.charge = math.max(meta.charge, 0) itemstack:set_metadata(set_item_meta(meta)) technic.set_RE_wear(itemstack, meta.charge, mining_drill_mk3_max_charge) end return itemstack end mining_drill_mode_text = { {S("Single node.")}, {S("3 nodes deep.")}, {S("3 nodes wide.")}, {S("3 nodes tall.")}, {S("3x3 nodes.")}, } function mining_drill_mk2_setmode(user,itemstack) local player_name=user:get_player_name() local item=itemstack:to_table() local meta=get_item_meta(item["metadata"]) if meta==nil then meta={} mode=0 end if meta["mode"]==nil then minetest.chat_send_player(player_name, S("Hold shift and use to change Mining Drill Mk%d modes."):format(2)) meta["mode"]=0 mode=0 end mode=(meta["mode"]) mode=mode+1 if mode>=5 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(2, mode)..": "..mining_drill_mode_text[mode][1]) item["name"]="technic:mining_drill_mk2_"..mode meta["mode"]=mode item["metadata"]=set_item_meta(meta) itemstack:replace(item) return itemstack end function mining_drill_mk3_setmode(user,itemstack) local player_name=user:get_player_name() local item=itemstack:to_table() local meta=get_item_meta(item["metadata"]) if meta==nil then meta={} mode=0 end if meta["mode"]==nil then minetest.chat_send_player(player_name, S("Hold shift and use to change Mining Drill Mk%d modes."):format(3)) meta["mode"]=0 mode=0 end mode=(meta["mode"]) mode=mode+1 if mode>=6 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(3, mode)..": "..mining_drill_mode_text[mode][1]) item["name"]="technic:mining_drill_mk3_"..mode meta["mode"]=mode item["metadata"]=set_item_meta(meta) itemstack:replace(item) return itemstack end technic/tools/mining_lasers.lua
@@ -150,7 +150,7 @@ inventory_image = "technic_mining_laser_mk"..m[1]..".png", stack_max = 1, on_use = function(itemstack, user) local meta = get_item_meta(itemstack:get_metadata()) local meta = minetest.deserialize(itemstack:get_metadata()) if not meta or not meta.charge then return end @@ -158,7 +158,7 @@ laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1]) meta.charge = meta.charge - 400 technic.set_RE_wear(itemstack, meta.charge, m[3]) itemstack:set_metadata(set_item_meta(meta)) itemstack:set_metadata(minetest.serialize(meta)) end return itemstack end, technic/tools/sonic_screwdriver.lua
@@ -22,7 +22,7 @@ if node.param2 == nil then return end local meta1 = get_item_meta(itemstack:get_metadata()) local meta1 = minetest.deserialize(itemstack:get_metadata()) if not meta1 or not meta1.charge then return end @@ -48,7 +48,7 @@ minetest.swap_node(pos, node) meta1.charge = meta1.charge - 100 itemstack:set_metadata(set_item_meta(meta1)) itemstack:set_metadata(minetest.serialize(meta1)) technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge) end end