Added Sonic Screwdriver
authorMaciej Kasatkin <mk@realbadangel.pl>
Wed, 12 Sep 2012 00:22:18 +0000 (02:22 +0200)
committerMaciej Kasatkin <mk@realbadangel.pl>
Wed, 12 Sep 2012 00:22:18 +0000 (02:22 +0200)
battery_box.lua
init.lua
screwdriver.lua
sonic_screwdriver.lua [new file with mode: 0644]
sounds/technic_sonic_screwdriver.ogg [new file with mode: 0644]

index 120ca4256b5f237a8e7736ae403cc4f7863213d5..dae2c0f79803ac5211a1bd2cd835d2f695a82b15 100644 (file)
@@ -12,6 +12,7 @@ end
 register_power_tool ("technic:mining_drill",60000)
 register_power_tool ("technic:laser_mk1",40000)
 register_power_tool ("technic:battery",10000)
+register_power_tool ("technic:sonic_screwdriver",15000)
 
 minetest.register_alias("battery", "technic:battery")
 minetest.register_alias("battery_box", "technic:battery_box")
index 4197e58924d45c67ed926ec325df441890f5a195..3334798d719970f5705c8e68748c3d5df64ce802 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -40,6 +40,7 @@ dofile(minetest.get_modpath("technic").."/alloy_furnace.lua")
 dofile(minetest.get_modpath("technic").."/items.lua")
 dofile(minetest.get_modpath("technic").."/mining_drill.lua")
 dofile(minetest.get_modpath("technic").."/screwdriver.lua")
+dofile(minetest.get_modpath("technic").."/sonic_screwdriver.lua")
 
 
 function has_locked_chest_privilege(meta, player)
index aebef80691e41c575f670f74d70dd4b432ee8699..d58d11a3c7f704040e37c788547e0af4035fb1b1 100644 (file)
@@ -8,8 +8,7 @@
                    local node=minetest.env:get_node(pos)
                    local node_name=node.name
                    if node.param2==nil  then return end
-                    print (node_name)
-                   -- Get ready to set the param2
+                   -- Get ready to set the param2
                     local n = node.param2
                     n = n+1
                     if n == 4 then n = 0 end
@@ -17,8 +16,7 @@
                     local meta = minetest.env:get_meta(pos)
                     local meta0 = meta:to_table()
                     node.param2 = n
-                    print(node_name)
-                   minetest.env:set_node(pos,node)
+                   minetest.env:set_node(pos,node)
                     meta = minetest.env:get_meta(pos)
                     meta:from_table(meta0)
                    local item=itemstack:to_table()
diff --git a/sonic_screwdriver.lua b/sonic_screwdriver.lua
new file mode 100644 (file)
index 0000000..636bd03
--- /dev/null
@@ -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"}
+            }
+    })
diff --git a/sounds/technic_sonic_screwdriver.ogg b/sounds/technic_sonic_screwdriver.ogg
new file mode 100644 (file)
index 0000000..471bb72
Binary files /dev/null and b/sounds/technic_sonic_screwdriver.ogg differ