mirror of
https://git.0x7be.net/dirk/uniham.git
synced 2024-11-22 07:13:49 +01:00
hammer registration documentation/function update
This commit is contained in:
parent
290763eeeb
commit
7495124061
@ -8,11 +8,39 @@ local use_hammer = uniham.use_hammer
|
|||||||
-- name = 'Name of the hammer',
|
-- name = 'Name of the hammer',
|
||||||
-- head = 'head_material_texture.png',
|
-- head = 'head_material_texture.png',
|
||||||
-- craft = 'crafting:material',
|
-- craft = 'crafting:material',
|
||||||
|
-- on_use = on_use_function,
|
||||||
-- uses = 123,
|
-- uses = 123,
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
|
-- The `name` will be shown as tooltip on hovering the item in the inventory
|
||||||
|
-- and will be used as it is.
|
||||||
|
--
|
||||||
|
-- `head` is a texture that is used as base for the hammer head texture mask.
|
||||||
|
-- To change the mask textture packs need to add `uniham_head_mask.png` with
|
||||||
|
-- another file. All black pixels will become transparent.
|
||||||
|
--
|
||||||
|
-- With `craft` the material to craft the hammer from is defined. Hammers are
|
||||||
|
-- crafted all the same with the provided material for x and a stick for s
|
||||||
|
--
|
||||||
|
-- [ ][x][ ]
|
||||||
|
-- [ ][s][x]
|
||||||
|
-- [s][ ][ ]
|
||||||
|
--
|
||||||
|
-- The function provided via `on_use` gets three parameters when called by the
|
||||||
|
-- hammer’s on_use action: `itemstack`, `player`, and `pointed_thing`. All of
|
||||||
|
-- those three parameters are defined by Minetest’s API. The function has to
|
||||||
|
-- modify and return the itemstack as needed.
|
||||||
|
--
|
||||||
|
-- If no function is provided the default function (replace nodes by the table
|
||||||
|
-- provided as `uniham.use_hammer` in mod loading state).
|
||||||
|
--
|
||||||
|
-- `uses` is added as `_uniham.uses` to the hammer’s item definition and can
|
||||||
|
-- be used by the custom `on_use` function. The built-in function (replacing
|
||||||
|
-- nodes) calculates the `add_wear` value from this.
|
||||||
|
--
|
||||||
-- @param short_id Unprefixed ID for the new hammer
|
-- @param short_id Unprefixed ID for the new hammer
|
||||||
-- @param definition Definition table as described
|
-- @param definition Definition table as described
|
||||||
|
-- @see <https://dev.minetest.net/on_use#on_use>
|
||||||
-- @return void
|
-- @return void
|
||||||
uniham.register_hammer = function (short_id, definition)
|
uniham.register_hammer = function (short_id, definition)
|
||||||
local texture = '([combine:16x16:-1,1=+s)^((+h^+m)^[makealpha:0,0,0)'
|
local texture = '([combine:16x16:-1,1=+s)^((+h^+m)^[makealpha:0,0,0)'
|
||||||
@ -22,17 +50,19 @@ uniham.register_hammer = function (short_id, definition)
|
|||||||
['+m'] = 'uniham_head_mask.png'
|
['+m'] = 'uniham_head_mask.png'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local on_use = definition.on_use or use_hammer
|
||||||
|
|
||||||
minetest.register_tool('uniham:'..short_id, {
|
minetest.register_tool('uniham:'..short_id, {
|
||||||
description = definition.name,
|
description = definition.name,
|
||||||
inventory_image = texture,
|
inventory_image = texture,
|
||||||
_uniham = { uses = definition.uses },
|
_uniham = { uses = definition.uses },
|
||||||
on_use = function(itemstack, player, pointed_thing)
|
on_use = function(itemstack, player, pointed_thing)
|
||||||
return use_hammer(itemstack, player, pointed_thing)
|
return on_use(itemstack, player, pointed_thing)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'uniham:'..short_id,
|
output = minetest.get_current_modname()..':'..short_id,
|
||||||
recipe = {
|
recipe = {
|
||||||
{ '', definition.craft, '' },
|
{ '', definition.craft, '' },
|
||||||
{ '', 'default:stick', definition.craft },
|
{ '', 'default:stick', definition.craft },
|
||||||
|
Loading…
Reference in New Issue
Block a user