| | |
| | | minetest.register_craft({ |
| | | output = 'technic:mining_drill', |
| | | recipe = { |
| | | {'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, |
| | | {'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, |
| | | {'', 'technic:red_energy_crystal', 'moreores:copper_ingot'}, |
| | | {'default:tin_ingot', 'technic:diamond_drill_head', 'default:tin_ingot'}, |
| | | {'technic:stainless_steel_ingot', 'basic_materials:motor', 'technic:stainless_steel_ingot'}, |
| | | {'', 'technic:red_energy_crystal', 'default:copper_ingot'}, |
| | | } |
| | | }) |
| | | minetest.register_craft({ |
| | |
| | | minetest.record_protection_violation(pos, player:get_player_name()) |
| | | return |
| | | end |
| | | local node=minetest.env:get_node(pos) |
| | | local node=minetest.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 |
| | | if node.name == "default:water_source" then minetest.remove_node(pos) return end |
| | | if node.name == "default:water_flowing" then minetest.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 math.abs(dir.x)>math.abs(dir.z) then |
| | | if dir.x>0 then return 0 end |
| | | return 1 |
| | | end |
| | |
| | | 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 |
| | |
| | | pos.z=pos.z-2 |
| | | drill_dig_it0 (pos,player) |
| | | pos.z=pos.z+1 |
| | | pos.y=pos.y-2 |
| | | 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-1 |
| | | drill_dig_it0 (pos,player) |
| | | pos.z=pos.z+1 |
| | | 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 |
| | |
| | | pos.x=pos.x-2 |
| | | drill_dig_it0 (pos,player) |
| | | pos.x=pos.x+1 |
| | | pos.y=pos.y-2 |
| | | 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-1 |
| | | drill_dig_it0 (pos,player) |
| | | pos.x=pos.x+1 |
| | | drill_dig_it0 (pos,player) |
| | |
| | | if mode == 1 then |
| | | drill_dig_it0(pos, player) |
| | | end |
| | | |
| | | |
| | | if mode == 2 then -- 3 deep |
| | | dir = drill_dig_it1(player) |
| | | local dir = drill_dig_it1(player) |
| | | if dir == 0 then -- x+ |
| | | drill_dig_it0(pos, player) |
| | | pos.x = pos.x + 1 |
| | |
| | | drill_dig_it0 (pos,player) |
| | | end |
| | | end |
| | | |
| | | |
| | | if mode==3 then -- 3 wide |
| | | dir=drill_dig_it1(player) |
| | | local dir = drill_dig_it1(player) |
| | | if dir==0 or dir==1 then -- x |
| | | drill_dig_it0 (pos,player) |
| | | pos.z=pos.z+1 |
| | |
| | | drill_dig_it0 (pos,player) |
| | | end |
| | | end |
| | | |
| | | |
| | | if mode==4 then -- 3 tall, selected in the middle |
| | | drill_dig_it0 (pos,player) |
| | | pos.y=pos.y-1 |
| | |
| | | drill_dig_it4(pos,player) |
| | | end |
| | | end |
| | | |
| | | |
| | | minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,}) |
| | | end |
| | | |
| | | local function pos_is_pointable(pos) |
| | | local node = minetest.env:get_node(pos) |
| | | local node = minetest.get_node(pos) |
| | | local nodedef = minetest.registered_nodes[node.name] |
| | | return nodedef and nodedef.pointable |
| | | end |
| | |
| | | local function mining_drill_mk2_setmode(user,itemstack) |
| | | local player_name=user:get_player_name() |
| | | local item=itemstack:to_table() |
| | | local mode = nil |
| | | local meta=minetest.deserialize(item["metadata"]) |
| | | if meta==nil then |
| | | meta={} |
| | |
| | | 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 |
| | | itemstack:set_name("technic:mining_drill_mk2_"..mode); |
| | | meta["mode"]=mode |
| | | item["metadata"]=minetest.serialize(meta) |
| | | itemstack:replace(item) |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | return itemstack |
| | | end |
| | | |
| | |
| | | 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 |
| | | itemstack:set_name("technic:mining_drill_mk3_"..mode); |
| | | meta["mode"]=mode |
| | | item["metadata"]=minetest.serialize(meta) |
| | | itemstack:replace(item) |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | return itemstack |
| | | end |
| | | |
| | | |
| | | 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 |
| | | local charge_to_take = cost_to_use(2, meta.mode) |
| | | if meta.charge >= charge_to_take then |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, false) |
| | | drill_dig_it(pos, user, meta.mode) |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[2]) |
| | | if not technic.creative_mode then |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[2]) |
| | | end |
| | | 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 |
| | | local charge_to_take = cost_to_use(3, meta.mode) |
| | | if meta.charge >= charge_to_take then |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, false) |
| | | drill_dig_it(pos, user, meta.mode) |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[3]) |
| | | if not technic.creative_mode then |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[3]) |
| | | end |
| | | end |
| | | return itemstack |
| | | end |
| | |
| | | end |
| | | local charge_to_take = cost_to_use(1, 1) |
| | | if meta.charge >= charge_to_take then |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, above) |
| | | local pos = minetest.get_pointed_thing_position(pointed_thing, false) |
| | | drill_dig_it(pos, user, 1) |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[1]) |
| | | if not technic.creative_mode then |
| | | meta.charge = meta.charge - charge_to_take |
| | | itemstack:set_metadata(minetest.serialize(meta)) |
| | | technic.set_RE_wear(itemstack, meta.charge, max_charge[1]) |
| | | end |
| | | end |
| | | return itemstack |
| | | end, |