Added screwdriver
authorMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 22:48:51 +0000 (00:48 +0200)
committerMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 22:48:51 +0000 (00:48 +0200)
init.lua
screwdriver.lua [new file with mode: 0644]
textures/technic_screwdriver.png [new file with mode: 0644]

index 6629b38f67c314ee8fe70259a30fc9baa798ccd0..4197e58924d45c67ed926ec325df441890f5a195 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -39,6 +39,7 @@ 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")
+dofile(minetest.get_modpath("technic").."/screwdriver.lua")
 
 
 function has_locked_chest_privilege(meta, player)
diff --git a/screwdriver.lua b/screwdriver.lua
new file mode 100644 (file)
index 0000000..c8aaa7b
--- /dev/null
@@ -0,0 +1,38 @@
+    minetest.register_tool("technic:screwdriver", {
+            description = "Screwdriver",
+            inventory_image = "technic_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
+                    print (node_name)
+                   -- Get ready to set the param2
+                    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
+                    print(node_name)
+                   minetest.env:set_node(pos,node)
+                    meta = minetest.env:get_meta(pos)
+                    meta:from_table(meta0)
+                    -- appropriatly set the wear of the screwdriver
+                   -- m = itemstack:get_wear()
+                   -- if m == 0 then m = 65535 end
+                   -- m = m-6554
+                   -- return {wear=m}
+            end,
+    })
+     
+    minetest.register_craft({
+            output = "technic:screwdriver",
+            recipe = {
+                    {"technic:stainless_steel_ingot"},
+                    {"default:stick"}
+            }
+    })
diff --git a/textures/technic_screwdriver.png b/textures/technic_screwdriver.png
new file mode 100644 (file)
index 0000000..bd2da22
Binary files /dev/null and b/textures/technic_screwdriver.png differ