diff options
author | Maciej Kasatkin <mk@realbadangel.pl> | 2012-09-12 02:22:18 +0200 |
---|---|---|
committer | Maciej Kasatkin <mk@realbadangel.pl> | 2012-09-12 02:22:18 +0200 |
commit | 1590ddce2d4b29be4f828651b29ae9263dc2b4d1 (patch) | |
tree | c6467ff8df1e6f0dad2c783f7a34f03e4cd0cbfc /sonic_screwdriver.lua | |
parent | d041c13ad822e30f7f9b9ed0624511968ce47e04 (diff) |
Added Sonic Screwdriver
Diffstat (limited to 'sonic_screwdriver.lua')
-rw-r--r-- | sonic_screwdriver.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sonic_screwdriver.lua b/sonic_screwdriver.lua new file mode 100644 index 0000000..636bd03 --- /dev/null +++ b/sonic_screwdriver.lua @@ -0,0 +1,47 @@ +sonic_screwdriver_max_charge=15000 + + minetest.register_tool("technic:sonic_screwdriver", { + description = "Sonic Screwdriver", + inventory_image = "technic_sonic_screwdriver.png", + on_use = function(itemstack, user, pointed_thing) + -- Must be pointing to facedir applicable node + if pointed_thing.type~="node" then return end + local pos=minetest.get_pointed_thing_position(pointed_thing,above) + local node=minetest.env:get_node(pos) + local node_name=node.name + if node.param2==nil then return end + item=itemstack:to_table() + local charge=tonumber((item["wear"])) + if charge ==0 then charge =65535 end + charge=get_RE_item_load(charge,sonic_screwdriver_max_charge) + if charge-100>0 then + minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 1.0, max_hear_distance = 10,}) + local n = node.param2 + n = n+1 + if n == 4 then n = 0 end + -- hacky_swap_node, unforunatly. + local meta = minetest.env:get_meta(pos) + local meta0 = meta:to_table() + node.param2 = n + minetest.env:set_node(pos,node) + meta = minetest.env:get_meta(pos) + meta:from_table(meta0) + + charge =charge-100; + charge=set_RE_item_load(charge,sonic_screwdriver_max_charge) + item["wear"]=tostring(charge) + itemstack:replace(item) + end + return itemstack + end, + + }) + + minetest.register_craft({ + output = "technic:sonic_screwdriver", + recipe = { + {"technic:green_energy_crystal"}, + {"technic:stainless_steel_ingot"}, + {"default:stick"} + } + }) |