Skip to content
Permalink
Browse files

Changes to Screwdriver to add new drivers.

A few screwdriver changes so that mod makers can add new screwdrivers with different wear levels.  Tried and tested with new diamond screwdriver :)
  • Loading branch information
tenplus1 authored and paramat committed Mar 3, 2016
1 parent 537f94c commit 51891122f2403abb102d149b79bdeeea5a66aa44
Showing with 4 additions and 5 deletions.
  1. +4 −5 mods/screwdriver/init.lua
@@ -18,10 +18,9 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2)
return false
end
end
local USES = 200

-- Handles rotation
local function screwdriver_handler(itemstack, user, pointed_thing, mode)
screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
if pointed_thing.type ~= "node" then
return
end
@@ -82,7 +81,7 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
end

if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / (USES - 1))
itemstack:add_wear(65535 / ((uses or 200) - 1))
end

return itemstack
@@ -93,11 +92,11 @@ minetest.register_tool("screwdriver:screwdriver", {
description = "Screwdriver (left-click rotates face, right-click rotates axis)",
inventory_image = "screwdriver.png",
on_use = function(itemstack, user, pointed_thing)
screwdriver_handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 200)
return itemstack
end,
on_place = function(itemstack, user, pointed_thing)
screwdriver_handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, 200)
return itemstack
end,
})

0 comments on commit 5189112

Please sign in to comment.
You can’t perform that action at this time.