mirror of
https://git.0x7be.net/dirk/uniham.git
synced 2024-11-21 23:03:54 +01:00
make the embossing effect configurable
This commit is contained in:
parent
a0b5fdd473
commit
430c5b1a84
@ -46,7 +46,10 @@ The *Unified Hammers API* can be used by calling the `uniham.register_hammer` fu
|
|||||||
```lua
|
```lua
|
||||||
uniham.register_hammer('my_cool_id', {
|
uniham.register_hammer('my_cool_id', {
|
||||||
name = 'My Cool Hammer',
|
name = 'My Cool Hammer',
|
||||||
head = 'mymod_my_cool_head_base_texture.png',
|
head = {
|
||||||
|
texture = 'mymod_my_cool_head_base_texture.png',
|
||||||
|
opacity = 51.2
|
||||||
|
}
|
||||||
--- Alternative to `head`, see description below
|
--- Alternative to `head`, see description below
|
||||||
-- texture = 'mymod_my_cool_hammer_texture.png',
|
-- texture = 'mymod_my_cool_hammer_texture.png',
|
||||||
craft = 'mymod:my_cool_item',
|
craft = 'mymod:my_cool_item',
|
||||||
@ -54,7 +57,7 @@ uniham.register_hammer('my_cool_id', {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
This registers a hammer with the name “My Cool Hammer” that has the ID `mymod:my_cool_id`. The head base texture is `mymod_my_cool_texture.png` and the texture is automatically masked to form a hammer head.
|
This registers a hammer with the name “My Cool Hammer” that has the ID `mymod:my_cool_id`. The head base texture is `mymod_my_cool_texture.png` with the embossing effect being 20% visible (51.2) and the texture is automatically masked to form a hammer head.
|
||||||
|
|
||||||
If instead of `head` the value `texture` is provided then the automatic texture generation is disabled and the hammer will get the texture defined by the `texture` value. If both values are added then the `texture` value is given precedence.
|
If instead of `head` the value `texture` is provided then the automatic texture generation is disabled and the hammer will get the texture defined by the `texture` value. If both values are added then the `texture` value is given precedence.
|
||||||
|
|
||||||
|
@ -5,56 +5,74 @@ local S = uniham.translator
|
|||||||
|
|
||||||
register_hammer('hammer_bronze', {
|
register_hammer('hammer_bronze', {
|
||||||
name = S('Bronze Hammer'),
|
name = S('Bronze Hammer'),
|
||||||
head = 'default_bronze_block.png',
|
head = {
|
||||||
|
texture = 'default_bronze_block.png',
|
||||||
|
},
|
||||||
craft = 'default:bronze_ingot',
|
craft = 'default:bronze_ingot',
|
||||||
uses = 150
|
uses = 150
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_diamond', {
|
register_hammer('hammer_diamond', {
|
||||||
name = S('Diamond Hammer'),
|
name = S('Diamond Hammer'),
|
||||||
head = 'default_diamond_block.png',
|
head = {
|
||||||
|
texture = 'default_diamond_block.png',
|
||||||
|
opacity = 120
|
||||||
|
},
|
||||||
craft = 'default:diamond',
|
craft = 'default:diamond',
|
||||||
uses = 300
|
uses = 300
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_gold', {
|
register_hammer('hammer_gold', {
|
||||||
name = S('Golden Hammer'),
|
name = S('Golden Hammer'),
|
||||||
head = 'default_gold_block.png',
|
head = {
|
||||||
|
texture = 'default_gold_block.png',
|
||||||
|
},
|
||||||
craft = 'default:gold_ingot',
|
craft = 'default:gold_ingot',
|
||||||
uses = 100
|
uses = 100
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_mese', {
|
register_hammer('hammer_mese', {
|
||||||
name = S('Mese Hammer'),
|
name = S('Mese Hammer'),
|
||||||
head = 'default_mese_block.png',
|
head = {
|
||||||
|
texture = 'default_mese_block.png',
|
||||||
|
},
|
||||||
craft = 'default:mese_crystal',
|
craft = 'default:mese_crystal',
|
||||||
uses = 350
|
uses = 350
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_obsidian', {
|
register_hammer('hammer_obsidian', {
|
||||||
name = S('Obsidian Hammer'),
|
name = S('Obsidian Hammer'),
|
||||||
head = 'default_obsidian_block.png',
|
head = {
|
||||||
|
texture = 'default_obsidian_block.png',
|
||||||
|
opacity = 25
|
||||||
|
},
|
||||||
craft = 'default:obsidian_shard',
|
craft = 'default:obsidian_shard',
|
||||||
uses = 400
|
uses = 400
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_steel', {
|
register_hammer('hammer_steel', {
|
||||||
name = S('Steel Hammer'),
|
name = S('Steel Hammer'),
|
||||||
head = 'default_steel_block.png',
|
head = {
|
||||||
|
texture = 'default_steel_block.png',
|
||||||
|
},
|
||||||
craft = 'default:steel_ingot',
|
craft = 'default:steel_ingot',
|
||||||
uses = 200
|
uses = 200
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_stone', {
|
register_hammer('hammer_stone', {
|
||||||
name = S('Stone Hammer'),
|
name = S('Stone Hammer'),
|
||||||
head = 'default_stone.png',
|
head = {
|
||||||
|
texture = 'default_stone.png',
|
||||||
|
},
|
||||||
craft = 'default:cobble',
|
craft = 'default:cobble',
|
||||||
uses = 70
|
uses = 70
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_wood', {
|
register_hammer('hammer_wood', {
|
||||||
name = S('Wooden Hammer'),
|
name = S('Wooden Hammer'),
|
||||||
head = 'default_wood.png',
|
head = {
|
||||||
|
texture = 'default_wood.png',
|
||||||
|
},
|
||||||
craft = 'default:wood',
|
craft = 'default:wood',
|
||||||
uses = 30
|
uses = 30
|
||||||
})
|
})
|
||||||
|
@ -5,14 +5,18 @@ local S = uniham.translator
|
|||||||
|
|
||||||
register_hammer('hammer_mithril', {
|
register_hammer('hammer_mithril', {
|
||||||
name = S('Mithril Hammer'),
|
name = S('Mithril Hammer'),
|
||||||
head = 'moreores_mithril_block.png',
|
head = {
|
||||||
|
texture = 'moreores_mithril_block.png',
|
||||||
|
},
|
||||||
craft = 'moreores:mithril_ingot',
|
craft = 'moreores:mithril_ingot',
|
||||||
uses = 450
|
uses = 450
|
||||||
})
|
})
|
||||||
|
|
||||||
register_hammer('hammer_silver', {
|
register_hammer('hammer_silver', {
|
||||||
name = S('Silver Hammer'),
|
name = S('Silver Hammer'),
|
||||||
head = 'moreores_silver_block.png',
|
head = {
|
||||||
|
texture = 'moreores_silver_block.png',
|
||||||
|
},
|
||||||
craft = 'moreores:silver_ingot',
|
craft = 'moreores:silver_ingot',
|
||||||
uses = 250
|
uses = 250
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,10 @@ local crush_nodes = uniham.crush_nodes
|
|||||||
--
|
--
|
||||||
-- definition = {
|
-- definition = {
|
||||||
-- name = 'Name of the hammer',
|
-- name = 'Name of the hammer',
|
||||||
-- head = 'head_material_texture.png',
|
-- head = {
|
||||||
|
-- texture = 'head_material_texture.png',
|
||||||
|
-- opacity = 20
|
||||||
|
-- },
|
||||||
-- texture = 'hammer_texture.png',
|
-- texture = 'hammer_texture.png',
|
||||||
-- craft = 'crafting:material',
|
-- craft = 'crafting:material',
|
||||||
-- on_use = on_use_function,
|
-- on_use = on_use_function,
|
||||||
@ -16,9 +19,16 @@ local crush_nodes = uniham.crush_nodes
|
|||||||
-- The `name` will be shown as tooltip on hovering the item in the inventory
|
-- The `name` will be shown as tooltip on hovering the item in the inventory
|
||||||
-- and will be used as it is.
|
-- and will be used as it is.
|
||||||
--
|
--
|
||||||
-- `head` is a texture that is used as base for the hammer head texture mask.
|
-- `head` is a texture table containing two entries. The `texture` entry
|
||||||
|
-- defines the texture that is used as base for the hammer head texture mask.
|
||||||
|
-- The `opacity` entry is the opacity value between 0 (fully transparent) and
|
||||||
|
-- 255 (fully visible) of the embossing effect. When omitting the opacity
|
||||||
|
-- value, 51.2 will be used.
|
||||||
|
--
|
||||||
-- To change the mask textture packs need to add `uniham_head_mask.png` with
|
-- To change the mask textture packs need to add `uniham_head_mask.png` with
|
||||||
-- another file. All black pixels will become transparent.
|
-- another file. All black pixels will become transparent. To change the
|
||||||
|
-- embossing effect add `uniham_emboss.png` with transparent backgground. The
|
||||||
|
-- embossing texture is simply overlayed over the generated head texture.
|
||||||
--
|
--
|
||||||
-- Instead of `head` the entry `texture` can be used. This does not auto-create
|
-- Instead of `head` the entry `texture` can be used. This does not auto-create
|
||||||
-- The hammer texture but uses the given texture file as hammer texture. If
|
-- The hammer texture but uses the given texture file as hammer texture. If
|
||||||
@ -54,17 +64,20 @@ local crush_nodes = uniham.crush_nodes
|
|||||||
-- @return void
|
-- @return void
|
||||||
uniham.register_hammer = function (short_id, definition)
|
uniham.register_hammer = function (short_id, definition)
|
||||||
local on_use = definition.on_use or crush_nodes
|
local on_use = definition.on_use or crush_nodes
|
||||||
local autotexture = '([combine:16x16:-1,1=+s)^((+h^+m)^[makealpha:0,0,0)'
|
local autotexture = '(([combine:16x16:-1,1=+s)^((+h^+m)^[makealpha:0,0,0))'
|
||||||
local hammer_id = minetest.get_current_modname()..':'..short_id
|
local hammer_id = minetest.get_current_modname()..':'..short_id
|
||||||
local texture = ''
|
local texture = ''
|
||||||
|
local opacity = ''
|
||||||
|
|
||||||
if definition.head and not definition.texture then
|
if definition.head and not definition.texture then
|
||||||
texture = autotexture:gsub('+.', {
|
texture = autotexture:gsub('+.', {
|
||||||
['+s'] = 'default_stick.png',
|
['+s'] = 'default_stick.png',
|
||||||
['+h'] = definition.head,
|
['+h'] = definition.head.texture,
|
||||||
['+m'] = 'uniham_head_mask.png'
|
['+m'] = 'uniham_head_mask.png'
|
||||||
})
|
})
|
||||||
texture = '(('..texture..')^(uniham_emboss.png^[opacity:51.2))'
|
|
||||||
|
opacity = definition.head.opacity or 51.2
|
||||||
|
texture = '('..texture..'^(uniham_emboss.png^[opacity:'..opacity..'))'
|
||||||
end
|
end
|
||||||
|
|
||||||
if definition.texture then
|
if definition.texture then
|
||||||
|
Loading…
Reference in New Issue
Block a user