Added Mining Drill
authorMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 16:47:09 +0000 (18:47 +0200)
committerMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 16:47:09 +0000 (18:47 +0200)
electric.lua
init.lua
items.lua
mining_drill.lua [new file with mode: 0644]
textures/technic_diamond_drill_head.png [new file with mode: 0644]
textures/technic_doped_silicon_wafer.png [new file with mode: 0644]
textures/technic_mining_drill.png [new file with mode: 0644]
textures/technic_silicon_wafer.png [new file with mode: 0644]

index b4c6ccad57c0b2eb7a0854fb6db97d82d795d0e8..deaa59625ecf3970a5f0b57c42c2249481fabc79 100644 (file)
@@ -338,6 +338,27 @@ minetest.register_abm({
                end
                end
                meta:set_float("battery_charge",charge)
+               
+               if inv:is_empty("src")==false  then 
+               srcstack = inv:get_stack("src", 1)
+               src_item=srcstack:to_table()
+               if src_item["name"]== "technic:mining_drill" then
+               local load1=tonumber((src_item["wear"])) 
+               load1=get_RE_item_load(load1,60000)
+               load_step=1000
+               if load1<60000 and charge>0 then 
+                if charge-load_step<0 then load_step=charge end
+                if load1+load_step>60000 then load_step=60000-load1 end
+               load1=load1+load_step
+               charge=charge-load_step
+               load1=set_RE_item_load(load1,60000)
+               src_item["wear"]=tostring(load1)
+               inv:set_stack("src", 1, src_item)
+               end             
+               end
+               end
+               meta:set_float("battery_charge",charge)
+
 
 
                if inv:is_empty("dst") == false then 
index a41b11a4e7a14bac58b230e137e9bca8c42831af..fc921d6511de05361a0ac126a64d7834775889c3 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -37,6 +37,7 @@ dofile(minetest.get_modpath("technic").."/geothermal.lua")
 dofile(minetest.get_modpath("technic").."/water_mill.lua")
 dofile(minetest.get_modpath("technic").."/alloy_furnace.lua")
 dofile(minetest.get_modpath("technic").."/items.lua")
+dofile(minetest.get_modpath("technic").."/mining_drill.lua")
 
 
 function has_locked_chest_privilege(meta, player)
index e026ae9a55c9eeba7853cb83c74415e6ac448bcc..f61fd6a6961fdbc53c6f7fb45fe47539a72d1d99 100644 (file)
--- a/items.lua
+++ b/items.lua
@@ -11,7 +11,7 @@ minetest.register_craftitem( "technic:doped_silicon_wafer", {
 })
 
 minetest.register_craft({
-       output = 'pipeworks:tube_000000 8',
+       output = 'pipeworks:tube_000000 9',
        recipe = {
                {'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
                {'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
diff --git a/mining_drill.lua b/mining_drill.lua
new file mode 100644 (file)
index 0000000..78c11a4
--- /dev/null
@@ -0,0 +1,60 @@
+mining_drill_max_charge=60000
+
+minetest.register_tool("technic:mining_drill", {
+       description = "Mining Drill",
+       inventory_image = "technic_mining_drill.png",
+       stack_max = 1,
+       on_use = function(itemstack, user, pointed_thing)
+               if pointed_thing.type=="node" then 
+               item=itemstack:to_table()
+               local charge=tonumber((item["wear"])) 
+               if charge ==0 then charge =65535 end
+               if charge ==65535 then charge =1 end
+               charge=get_RE_item_load(charge,laser_mk1_max_charge)
+               if charge-400>0 then
+                drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user)
+                charge =charge-400;    
+               charge=set_RE_item_load(charge,laser_mk1_max_charge)
+               item["wear"]=tostring(charge)
+               itemstack:replace(item)
+               end
+               return itemstack
+               end
+       end,
+})
+
+minetest.register_craft({
+       output = 'technic:mining_drill',
+       recipe = {
+               {'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
+               {'technic:stainless_steel_ingot', 'technic:red_energy_crystal', 'technic:stainless_steel_ingot'},
+               {'', 'moreores:copper_ingot', ''},
+       }
+})
+
+
+
+
+
+
+function drill_dig_it (pos, player)            
+       local node=minetest.env:get_node(pos)
+       if node.name == "air" 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 == "ignore" then minetest.env:remove_node(pos) return end
+
+       if player then 
+       local drops = minetest.get_node_drops(node.name, "default:pick_mese")
+       if player:get_inventory() then
+               local _, dropped_item
+               for _, dropped_item in ipairs(drops) do
+                       player:get_inventory():add_item("main", dropped_item)
+               end
+       end
+       minetest.env:remove_node(pos)
+       end
+
+end
\ No newline at end of file
diff --git a/textures/technic_diamond_drill_head.png b/textures/technic_diamond_drill_head.png
new file mode 100644 (file)
index 0000000..e3d31e8
Binary files /dev/null and b/textures/technic_diamond_drill_head.png differ
diff --git a/textures/technic_doped_silicon_wafer.png b/textures/technic_doped_silicon_wafer.png
new file mode 100644 (file)
index 0000000..6ff06a6
Binary files /dev/null and b/textures/technic_doped_silicon_wafer.png differ
diff --git a/textures/technic_mining_drill.png b/textures/technic_mining_drill.png
new file mode 100644 (file)
index 0000000..171888d
Binary files /dev/null and b/textures/technic_mining_drill.png differ
diff --git a/textures/technic_silicon_wafer.png b/textures/technic_silicon_wafer.png
new file mode 100644 (file)
index 0000000..78aef20
Binary files /dev/null and b/textures/technic_silicon_wafer.png differ