summaryrefslogtreecommitdiff
path: root/chainsaw.lua
diff options
context:
space:
mode:
authorMaciej Kasatkin <mk@realbadangel.pl>2012-10-23 01:32:29 +0200
committerMaciej Kasatkin <mk@realbadangel.pl>2012-10-23 01:32:29 +0200
commitd503d3d7578c430cafc9e4dbb999faf685063a38 (patch)
tree021a9821b432f431ae4567c13d953ad5045c7a69 /chainsaw.lua
parent81943958a6f928db41148a2bdba9fc0d5fbfb0a4 (diff)
Added Chainsaw
Diffstat (limited to 'chainsaw.lua')
-rw-r--r--chainsaw.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/chainsaw.lua b/chainsaw.lua
new file mode 100644
index 0000000..dc1b409
--- /dev/null
+++ b/chainsaw.lua
@@ -0,0 +1,60 @@
+chainsaw_max_charge=30000
+
+minetest.register_tool("technic:chainsaw", {
+ description = "Chainsaw",
+ inventory_image = "technic_chainsaw.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
+ charge=get_RE_item_load(charge,mining_drill_max_charge)
+ charge_to_take=600;
+ if charge-charge_to_take>0 then
+ charge_to_take=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge_to_take)
+ charge=charge-charge_to_take;
+ charge=set_RE_item_load(charge,mining_drill_max_charge)
+ item["wear"]=tostring(charge)
+ itemstack:replace(item)
+ end
+ return itemstack
+ end
+ end,
+})
+
+minetest.register_craft({
+ output = 'technic:chainsaw',
+ recipe = {
+ {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
+ {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
+ {'','','moreores:copper_ingot'},
+ }
+})
+
+
+
+
+timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}
+
+function chainsaw_dig_it (pos, player,charge_to_take)
+ charge_to_take=0
+ local node=minetest.env:get_node(pos)
+ local i=1
+ while timber_nodenames[i]~=nil do
+ if node.name==timber_nodenames[i] then
+ charge_to_take=600
+ np={x=pos.x, y=pos.y, z=pos.z}
+ while minetest.env:get_node(np).name==timber_nodenames[i] do
+ minetest.env:remove_node(np)
+ minetest.env:add_item(np, timber_nodenames[i])
+ np={x=np.x, y=np.y+1, z=np.z}
+ end
+ minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,})
+ return charge_to_take
+ end
+ i=i+1
+ end
+
+return charge_to_take
+end \ No newline at end of file