forked from minetest/minetest_game
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 :)
This commit is contained in:
parent
537f94c28e
commit
51891122f2
@ -18,10 +18,9 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local USES = 200
|
|
||||||
|
|
||||||
-- Handles rotation
|
-- 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
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -82,7 +81,7 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535 / (USES - 1))
|
itemstack:add_wear(65535 / ((uses or 200) - 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -93,11 +92,11 @@ minetest.register_tool("screwdriver:screwdriver", {
|
|||||||
description = "Screwdriver (left-click rotates face, right-click rotates axis)",
|
description = "Screwdriver (left-click rotates face, right-click rotates axis)",
|
||||||
inventory_image = "screwdriver.png",
|
inventory_image = "screwdriver.png",
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
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
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
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
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user