Patch for add def (#5)

* Add def for add more settings.

* Fix type for readme

* Typo fix

* Simplify function and call for table empty

* Typo Fix

* Minor fix Readme.md

* Refix Readme.md
This commit is contained in:
Jat15 2018-11-03 05:57:48 +01:00 committed by sofar
parent e9af1ed9d5
commit 0f71c8ff94
2 changed files with 72 additions and 56 deletions

View File

@ -4,22 +4,43 @@ The majority of this code was taken (and altered significantly) from Calinou's [
The Letter Cutter textures use parts of the default wood and tree textures made by Blockmen and Cisoun respectively. The Letter Cutter textures use parts of the default wood and tree textures made by Blockmen and Cisoun respectively.
####Allowing letters to be made from nodes: #### Allowing letters to be made from nodes:
Use this code to allow blocks to have letters registered from them: Use this code to allow blocks to have letters registered from them:
```lua ```lua
letters.register_letters(modname, subname, from_node, description, tiles) letters.register_letters(modname, subname, from_node, description, tiles, def)
``` ```
Modname is the mod that the node belongs to. - Modname is the mod that the node belongs to.
Subname is the actual name of the node. - Subname is the actual name of the node.
From_nobe is the node that the letters will be crafted from (Usually modname:subname). - From_node is the node that the letters will be crafted from (Usually modname:subname).
Description is the description of the node. - Description is the description of the node.
Tiles defines the image that will be used with the node. - Tiles defines the image that will be used with the node.
- Def (optional) may contain additional node definition parameters. Some might be overwritten to make the letters look and work as intended.
For example, if I wanted to register marble, from the mod darkage, this is the code I would use: For example, if I wanted to register marble, from the mod darkage, this is the code I would use:
```lua ```lua
letters.register_letters("darkage", "marble", "darkage:marble", "Marble", "darkage_marble.png") letters.register_letters("darkage", "marble", "darkage:marble", "Marble", "darkage_marble.png")
``` ```
Add letters with unifieddye.
```lua
letters.register_letters("darkage",
"marble",
"darkage:marble",
"Marble",
"darkage_marble.png",
{
paramtype2 = "colorwallmounted",
palette = "unifieddyes_palette_colorwallmounted.png",
groups = {
not_in_creative_inventory = 1,
not_in_craft_guide = 1,
oddly_breakable_by_hand = 1,
attached_node = 1,
ud_param2_colorable = 1
}
}
)
```
You will need to add letters as a dependency to your mod, or include the registrations is the code: You will need to add letters as a dependency to your mod, or include the registrations is the code:
```lua ```lua
if minetest.get_modpath("letters") then if minetest.get_modpath("letters") then

View File

@ -30,55 +30,50 @@ letters = {
letter_cutter = {} letter_cutter = {}
letter_cutter.known_nodes = {} letter_cutter.known_nodes = {}
function letters.register_letters(modname, subname, from_node, description, tiles) function letters.register_letters(modname, subname, from_node, description, tiles, def)
for _, row in ipairs(letters) do
local namel = subname.. "_letter_" ..row[1] def = def and table.copy(def) or {}
local nameu = subname.. "_letter_" ..row[2]
local descl = description.. " " ..row[3] --default node
local descu = description.. " " ..row[4] def.drawtype = "signlike"
local tilesl = tiles.. "^letters_" ..row[1].. "_overlay.png^[makealpha:255,126,126" def.paramtype = "light"
local tilesu = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126" def.paramtype2 = def.paramtype2 or "wallmounted"
local groups = {not_in_creative_inventory=1, not_in_craft_guide=1, oddly_breakable_by_hand=1, attached_node=1} def.sunlight_propagates = true
minetest.register_node(":" ..modname..":"..namel, { def.is_ground_content = false
description = descl, def.walkable = false
drawtype = "signlike", def.selection_box = {
tiles = {tilesl}, type = "wallmounted"
inventory_image = tilesl, --wall_top = <default>
wield_image = tilesl, --wall_bottom = <default>
paramtype = "light", --wall_side = <default>
paramtype2 = "wallmounted", }
sunlight_propagates = true, def.groups = def.groups or {
is_ground_content = false, not_in_creative_inventory = 1,
walkable = false, not_in_craft_guide = 1,
selection_box = { oddly_breakable_by_hand = 1,
type = "wallmounted", attached_node = 1
--wall_top = <default> }
--wall_bottom = <default> def.legacy_wallmounted = false
--wall_side = <default>
},
groups = groups, for _, row in ipairs(letters) do
legacy_wallmounted = false,
}) def = table.copy(def)
minetest.register_node(":" ..modname..":"..nameu, { def.description = description.. " " ..row[3]
description = descu, def.inventory_image = tiles.. "^letters_" ..row[1].. "_overlay.png^[makealpha:255,126,126"
drawtype = "signlike", def.wield_image = def.inventory_image
tiles = {tilesu}, def.tiles = {def.inventory_image}
inventory_image = tilesu,
wield_image = tilesu, minetest.register_node(":" ..modname..":"..subname.. "_letter_" ..row[1],def)
paramtype = "light",
paramtype2 = "wallmounted", def = table.copy(def)
sunlight_propagates = true, def.description = description.. " " ..row[4]
is_ground_content = false, def.inventory_image = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126"
walkable = false, def.wield_image = def.inventory_image
selection_box = { def.tiles = {def.inventory_image}
type = "wallmounted",
--wall_top = <default> minetest.register_node(":" ..modname..":"..subname.. "_letter_" ..row[2], def)
--wall_bottom = <default>
--wall_side = <default>
},
groups = groups,
legacy_wallmounted = false,
})
--[[minetest.register_craft({ --[[minetest.register_craft({
output = from_node, output = from_node,
recipe = { recipe = {