mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-04 23:31:05 +01:00
Added in Documentation, changed the inventory image to be more minecraft-like (hand made), changed some licensing, and tracked down an out of place debug log line.
This commit is contained in:
parent
7095876af1
commit
d4b9918ed4
7 changed files with 608 additions and 50 deletions
|
@ -23,7 +23,12 @@ License of code and font: MIT License
|
|||
Font source: 04.jp.org, some modifications and additions were made (added support for Latin-1 Supplement)
|
||||
Original font license text states: “YOU MAY USE THEM AS YOU LIKE” (in about.gif file distributed with the font)
|
||||
|
||||
License of textures: See README.md in top directory of MineClone 2.
|
||||
License of textures: See README.md in top directory of MineClone 2, with the exception of the following:
|
||||
default_sign.png, default_sign_dark.png, default_sign_greyscale.png, mcl_signs_sign_dark.png,
|
||||
mcl_signs_sign_greyscale.png are licensed as follows:
|
||||
Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (https://creativecommons.org/licenses/by-sa/4.0/).
|
||||
Credit Michieal (Faerraven). The extra sign textures are provided for you to use, modify, etc., with the goal being to
|
||||
make the game better. (All of these textures were changed / created by me, to make them usable / better.)
|
||||
|
||||
License of models: GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
|
|
122
mods/ITEMS/mcl_signs/SIGNS_API_DOC.txt
Normal file
122
mods/ITEMS/mcl_signs/SIGNS_API_DOC.txt
Normal file
|
@ -0,0 +1,122 @@
|
|||
---
|
||||
--- Generated by EmmyLua.
|
||||
--- Created by Michieal (FaerRaven).
|
||||
--- DateTime: 10/22/22 3:44 PM
|
||||
---
|
||||
|
||||
SIGNS API
|
||||
|
||||
--- How to Use:
|
||||
|
||||
The simplest way to create a new sign is to use mcl_signs.register_sign [mcl_signs.register_sign (modname, color, _name,
|
||||
ttsign)]. It's an all-in-one sign creator. It makes use of the standard textures for the signs, and colors them based on
|
||||
the color code that you give it, and names it "mcl_signs:wall_sign" + _name. So, using the spruce sign to illustrate, it
|
||||
would be named "mcl_signs:wall_sign_sprucewood", as we made _name equal to "_sprucewood" after the name of the
|
||||
registered wood.
|
||||
|
||||
To create a sign with specific textures: use the mcl_signs.register_sign_custom [mcl_signs.register_sign_custom
|
||||
(modname, _name, tiles, color, inventory_image, wield_image, ttsign)]. Like the register_sign() function, this is also an
|
||||
all-in-one sign creation function. With this function you can designate what textures to use, and give them a specified
|
||||
color. This function follows the same naming conventions.
|
||||
|
||||
If you wish to override / recreate one of the predefined signs, you may also do that. The reregister_sign() and
|
||||
reregister_sign_custom() functions will replace an existing sign's definition with a new one. Caution, ONLY use this on
|
||||
existing signs. If the sign doesn't exist, use the regular register_sign* functions.
|
||||
|
||||
--- What the parameters mean, and what they do:
|
||||
|
||||
* modname: optional (pass "" or "false" to ignore), for using mcl_signs with other mods to allow the creation of a sign
|
||||
from the mod's wood (if installed). Use this to prevent failures of the specific mod is not installed that has the needed
|
||||
information (textures, wood, etc.) Setting this is important, because it prevents items from being registered if the
|
||||
mod in not installed.
|
||||
|
||||
* tiles: the texture file to use for the sign's node.
|
||||
|
||||
* color: color the texture file to use with this color. Use white (#FFFFFF) to negate the color, and just use the
|
||||
texture as is.
|
||||
|
||||
* inventory_image: the texture file to use for the sign's display in inventory.
|
||||
|
||||
* wield_image: the texture file to use for the sign's weilded (in hand) object.
|
||||
|
||||
* _name: the sign's name suffix, such as "_dark" or "_sprucewood", etc., appended to "wall_sign" or "standing_sign"
|
||||
|
||||
* ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign. ttsign stands
|
||||
for translated tooltip sign.
|
||||
|
||||
* wood_item_string: example: "mcl_core:wood", "mcl_core:sprucewood" or "mymod:mywood". This is used when defining the
|
||||
recipe for the sign.
|
||||
|
||||
--- Other Functions of Importance:
|
||||
|
||||
* register_dye [mcl_signs.register_dye (modname, item_name, color_code)] -- this registers a new dye that the sign knows
|
||||
about so that the player can color their signs with the dye.
|
||||
Parameters:
|
||||
modname: your mod / module's name. make sure to use this for compatibility.
|
||||
item_name: the item_string of the dye to register.
|
||||
color_code: the hex code for the color to make the lettering. Also called HTML color code. Ex. "#FFFFFF" is white.
|
||||
|
||||
* register_sign_craft [mcl_signs.register_sign_craft(modname, wood_item_string, _name)] -- this is what creates the
|
||||
recipes for the sign, and makes the sign "burnable". Typically called right after the register_sign* functions.
|
||||
Parameters:
|
||||
_name: MUST be the same name as used for the sign. So, if your sign _name is "_sprucewood" then this should be too.
|
||||
wood_item_string: the item_string of the wood to use for the sign's recipe. Example: "mcl_core:wood" (default oak).
|
||||
modname: like with the other functions that has this parameter, used to make sure that nothing breaks.
|
||||
|
||||
* make_lbm() [mcl_signs.make_lbm()] -- This innocuous function is very important. This is the function that makes the
|
||||
signs work after reloading the game. This function is the last to be called in your sign creation work flow. Note, you
|
||||
do not need to call this function after every definition, just at the end of the last definition.
|
||||
(See Example WorkFlow below.)
|
||||
|
||||
--- Example Workflow for sign creation.
|
||||
|
||||
* these are, at the time of writing, a selection of the actual signs' definitions. Note the functions called, and when.
|
||||
|
||||
-- ---------------------------- --
|
||||
-- Register Signs for use. --
|
||||
-- ---------------------------- --
|
||||
|
||||
-- sprucewood Sign
|
||||
mcl_signs.register_sign_custom("mcl_core", "_sprucewood",
|
||||
"mcl_signs_sign_dark.png","#ffffff", "default_sign_dark.png",
|
||||
"default_sign_dark.png", "Spruce Sign"
|
||||
)
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:sprucewood", "_sprucewood")
|
||||
|
||||
-- darkwood Sign
|
||||
mcl_signs.register_sign_custom("mcl_core", "_darkwood",
|
||||
"mcl_signs_sign_greyscale.png","#856443", "default_sign_greyscale.png",
|
||||
"default_sign_greyscale.png", "Dark Oak Sign"
|
||||
)
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:darkwood", "_darkwood")
|
||||
|
||||
-- acaciawood Sign
|
||||
mcl_signs.register_sign("mcl_core", "#ea7479", "_acaciawood", "Acacia Sign")
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:acaciawood", "_acaciawood")
|
||||
|
||||
-- junglewood Sign
|
||||
mcl_signs.register_sign("mcl_core", "#866249", "_junglewood", "Jungle Sign")
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:junglewood", "_junglewood")
|
||||
|
||||
-- Register the LBMs for the created signs.
|
||||
mcl_signs.make_lbm()
|
||||
|
||||
--- -----------------------------------------------------------------------------
|
||||
|
||||
* If you wish to use a recipe other than the standard sign recipe, you will need to define your own recipe. In doing so,
|
||||
use this output line:
|
||||
output = "mcl_signs:wall_sign" .. _name .. " 3",
|
||||
where _name is the same string that you have used throughout your sign's workflow. That way, when players make the recipe,
|
||||
they get your sign (x3).
|
||||
|
||||
--- Future landmarks on the horizon for the Signs API:
|
||||
|
||||
* Once the forthcoming Hanging Signs are in Minecraft, and we implement the code for them in here, hanging signs will
|
||||
automatically exist as part of the signs' package. You won't have to change any of your code, it'll just be more
|
||||
functional. :)
|
||||
|
||||
* if you have suggestions, comments, etc., please contact me on MineClone 2's Discord server.
|
||||
|
||||
And that... is all there is to it!
|
||||
|
||||
-- written by Michieal.
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Generated by EmmyLua.
|
||||
--- Created by Michieal (FaerRaven).
|
||||
--- DateTime: 10/14/22 4:05 PM
|
||||
---
|
||||
|
@ -25,6 +25,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
end)
|
||||
|
||||
-- This defines the text entity for the lettering of the sign.
|
||||
-- FIXME: Prevent entity destruction by /clearobjects
|
||||
minetest.register_entity("mcl_signs:text", {
|
||||
pointable = false,
|
||||
|
@ -90,19 +91,16 @@ mcl_signs.build_signs_info()
|
|||
-- ---------------------------- --
|
||||
-- Register Signs for use. --
|
||||
-- ---------------------------- --
|
||||
local mcl_colors_official = mcl_colors
|
||||
|
||||
-- Standard (original) Sign
|
||||
mcl_signs.register_sign("mcl_core", "#ffffff", "", "Sign")
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:wood", "")
|
||||
|
||||
-- birchwood Sign
|
||||
--mcl_signs.register_sign("mcl_core", "#d5cb8d", "_birchwood", "Birch Sign")
|
||||
-- birchwood Sign "#d5cb8d" / "#ffdba7"
|
||||
mcl_signs.register_sign_custom("mcl_core", "_birchwood",
|
||||
"mcl_signs_sign_greyscale.png",mcl_colors_official.YELLOW, "default_sign_greyscale.png",
|
||||
"mcl_signs_sign_greyscale.png","#ffdba7", "default_sign_greyscale.png",
|
||||
"default_sign_greyscale.png", "Birch Sign"
|
||||
)
|
||||
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:birchwood", "_birchwood")
|
||||
|
||||
-- sprucewood Sign
|
||||
|
@ -112,13 +110,11 @@ mcl_signs.register_sign_custom("mcl_core", "_sprucewood",
|
|||
)
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:sprucewood", "_sprucewood")
|
||||
|
||||
-- darkwood Sign
|
||||
--mcl_signs.register_sign("mcl_core","#291f1a", "_darkwood", "Dark Oak Sign")
|
||||
-- darkwood Sign "#291f1a" / "#856443"
|
||||
mcl_signs.register_sign_custom("mcl_core", "_darkwood",
|
||||
"mcl_signs_sign_greyscale.png","#856443", "default_sign_greyscale.png",
|
||||
"default_sign_greyscale.png", "Dark Oak Sign"
|
||||
)
|
||||
|
||||
mcl_signs.register_sign_craft("mcl_core", "mcl_core:darkwood", "_darkwood")
|
||||
|
||||
-- junglewood Sign
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Generated by EmmyLua.
|
||||
--- Created by Michieal (FaerRaven).
|
||||
--- DateTime: 10/14/22 4:05 PM
|
||||
---
|
||||
|
@ -439,6 +439,43 @@ mcl_signs.standing_standard = {
|
|||
_mcl_blast_resistance = 1,
|
||||
}
|
||||
|
||||
-- HELPER FUNCTIONS' VARIABLES
|
||||
local sign_glow = 6
|
||||
local Dyes_table = {
|
||||
{ "mcl_dye:aqua", mcl_colors_official.AQUA },
|
||||
{ "mcl_dye:black", mcl_colors_official.BLACK },
|
||||
{ "mcl_dye:blue", mcl_colors_official.BLUE },
|
||||
{ "mcl_dye:brown", mcl_colors_official.brown },
|
||||
{ "mcl_dye:cyan", mcl_signs.mcl_wool_colors.unicolor_cyan },
|
||||
{ "mcl_dye:green", mcl_colors_official.GREEN },
|
||||
{ "mcl_dye:dark_green", mcl_colors_official.DARK_GREEN },
|
||||
{ "mcl_dye:grey", mcl_colors_official.GRAY },
|
||||
{ "mcl_dye:dark_grey", mcl_colors_official.DARK_GRAY },
|
||||
{ "mcl_dye:lightblue", mcl_signs.mcl_wool_colors.unicolor_light_blue },
|
||||
{ "mcl_dye:lime", mcl_signs.unicolor_green_or_lime },
|
||||
{ "mcl_dye:magenta", mcl_colors_official.LIGHT_PURPLE },
|
||||
{ "mcl_dye:orange", mcl_signs.mcl_wool_colors.unicolor_orange },
|
||||
{ "mcl_dye:pink", mcl_signs.mcl_wool_colors.unicolor_light_red_pink },
|
||||
{ "mcl_dye:purple", mcl_colors_official.LIGHT_PURPLE },
|
||||
{ "mcl_dye:red", mcl_signs.mcl_wool_colors.unicolor_red },
|
||||
{ "mcl_dye:silver", mcl_signs.mcl_wool_colors.unicolor_grey },
|
||||
{ "mcl_dye:violet", mcl_colors_official.DARK_PURPLE },
|
||||
{ "mcl_dye:white", mcl_colors_official.WHITE },
|
||||
{ "mcl_dye:yellow", mcl_colors_official.YELLOW },
|
||||
}
|
||||
|
||||
local function update_sign_registry(type, name)
|
||||
if type == "wall" then
|
||||
table.insert(mcl_signs.registered_signs.wall_signs, name)
|
||||
end
|
||||
if type == "standing" then
|
||||
table.insert(mcl_signs.registered_signs.standing_signs, name)
|
||||
end
|
||||
if type == "hanging" then
|
||||
table.insert(mcl_signs.registered_signs.hanging_signs, name)
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_signs.make_lbm()
|
||||
|
||||
local registered_sign_nodenames = {}
|
||||
|
@ -468,49 +505,12 @@ function mcl_signs.make_lbm()
|
|||
|
||||
end
|
||||
|
||||
-- HELPER FUNCTIONS' VARIABLES
|
||||
local sign_glow = 6
|
||||
local Dyes_table = {
|
||||
{ "mcl_dye:aqua", mcl_colors_official.AQUA },
|
||||
{ "mcl_dye:black", mcl_colors_official.BLACK },
|
||||
{ "mcl_dye:blue", mcl_colors_official.BLUE },
|
||||
{ "mcl_dye:brown", mcl_colors_official.brown },
|
||||
{ "mcl_dye:cyan", mcl_signs.mcl_wool_colors.unicolor_cyan },
|
||||
{ "mcl_dye:green", mcl_colors_official.GREEN },
|
||||
{ "mcl_dye:dark_green", mcl_colors_official.DARK_GREEN },
|
||||
{ "mcl_dye:grey", mcl_colors_official.GRAY },
|
||||
{ "mcl_dye:dark_grey", mcl_colors_official.DARK_GRAY },
|
||||
{ "mcl_dye:lightblue", mcl_signs.mcl_wool_colors.unicolor_light_blue },
|
||||
{ "mcl_dye:lime", mcl_signs.unicolor_green_or_lime },
|
||||
{ "mcl_dye:magenta", mcl_colors_official.LIGHT_PURPLE },
|
||||
{ "mcl_dye:orange", mcl_signs.mcl_wool_colors.unicolor_orange },
|
||||
{ "mcl_dye:pink", mcl_signs.mcl_wool_colors.unicolor_light_red_pink },
|
||||
{ "mcl_dye:purple", mcl_colors_official.LIGHT_PURPLE },
|
||||
{ "mcl_dye:red", mcl_signs.mcl_wool_colors.unicolor_red },
|
||||
{ "mcl_dye:silver", mcl_signs.mcl_wool_colors.unicolor_grey },
|
||||
{ "mcl_dye:violet", mcl_colors_official.DARK_PURPLE },
|
||||
{ "mcl_dye:white", mcl_colors_official.WHITE },
|
||||
{ "mcl_dye:yellow", mcl_colors_official.YELLOW },
|
||||
}
|
||||
|
||||
function mcl_signs.register_dye (modname, item_name, color_code)
|
||||
if minetest.get_modpath(modname) then
|
||||
table.insert(Dyes_table, { item_name, color_code })
|
||||
end
|
||||
end
|
||||
|
||||
local function update_sign_registry(type, name)
|
||||
if type == "wall" then
|
||||
table.insert(mcl_signs.registered_signs.wall_signs, name)
|
||||
end
|
||||
if type == "standing" then
|
||||
table.insert(mcl_signs.registered_signs.standing_signs, name)
|
||||
end
|
||||
if type == "hanging" then
|
||||
table.insert(mcl_signs.registered_signs.hanging_signs, name)
|
||||
end
|
||||
end
|
||||
|
||||
--- Register a new sign, tint the textures, and gives it an unique node name. Creates both wall and standing signs.
|
||||
--- modname: optional (pass "" or "false" to ignore), for use with other mods to
|
||||
--- allow the creation of a sign from the mod's wood (if installed).
|
||||
|
@ -738,7 +738,6 @@ end
|
|||
---
|
||||
--- modname: optional (pass "" or "false" to ignore), for use with other mods to
|
||||
--- allow the creation of a sign from the mod's wood (if installed).
|
||||
--- type: "wall", "standing".
|
||||
---
|
||||
--- _name: the sign's name suffix, such as "_dark" or "_red", etc., appended to "wall_sign" or "standing_sign"
|
||||
---
|
||||
|
@ -948,6 +947,442 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
|
||||
end
|
||||
|
||||
--- Override an existing sign, tint the textures, and gives it an unique node name. Creates both wall and standing signs.
|
||||
--- modname: optional (pass "" or "false" to ignore), for use with other mods to
|
||||
--- allow the creation of a sign from the mod's wood (if installed).
|
||||
---
|
||||
--- color: the color code to color the base sign textures. must be a valid html color code.
|
||||
---
|
||||
--- _name: the sign's name suffix, such as "_dark" or "_red", etc., appended to "wall_sign" or "standing_sign"
|
||||
---
|
||||
--- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign.
|
||||
--- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign"
|
||||
function mcl_signs.reregister_sign (modname, color, _name, ttsign)
|
||||
local mod_name_pass = false
|
||||
if modname ~= "" and modname ~= "false" then
|
||||
if minetest.get_modpath(modname) then
|
||||
mod_name_pass = true
|
||||
end
|
||||
if mod_name_pass == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
local new_sign = {}
|
||||
|
||||
if color == nil or color == "" then
|
||||
color = "#FFFFFF"
|
||||
end
|
||||
|
||||
new_sign = table.copy(mcl_signs.wall_standard)
|
||||
new_sign.description = S(ttsign)
|
||||
|
||||
new_sign.wield_image = "(default_sign.png^[multiply:" .. color .. ")"
|
||||
new_sign.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" }
|
||||
new_sign.inventory_image = "(default_sign.png^[multiply:" .. color .. ")"
|
||||
|
||||
-- currently have to do this, because of how the base node placement works.
|
||||
new_sign.on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node_under = minetest.get_node(under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then
|
||||
return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
local dir = vector.subtract(under, above)
|
||||
|
||||
-- Only build when it's legal
|
||||
local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name]
|
||||
if not abovenodedef or abovenodedef.buildable_to == false then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(dir)
|
||||
local fdir = minetest.dir_to_facedir(dir)
|
||||
|
||||
local sign_info
|
||||
local nodeitem = ItemStack(itemstack)
|
||||
-- Ceiling
|
||||
if wdir == 0 then
|
||||
--how would you add sign to ceiling?
|
||||
return itemstack
|
||||
-- Floor
|
||||
elseif wdir == 1 then
|
||||
-- Standing sign
|
||||
|
||||
-- Determine the sign rotation based on player's yaw
|
||||
local yaw = pi * 2 - placer:get_look_horizontal()
|
||||
|
||||
-- Select one of 16 possible rotations (0-15)
|
||||
local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16)
|
||||
|
||||
if rotation_level > 15 then
|
||||
rotation_level = 0
|
||||
elseif rotation_level < 0 then
|
||||
rotation_level = 15
|
||||
end
|
||||
|
||||
-- The actual rotation is a combination of predefined mesh and facedir (see node definition)
|
||||
if rotation_level % 4 == 0 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign" .. _name)
|
||||
elseif rotation_level % 4 == 1 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name)
|
||||
elseif rotation_level % 4 == 2 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign45" .. _name)
|
||||
elseif rotation_level % 4 == 3 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name)
|
||||
end
|
||||
fdir = math.floor(rotation_level / 4)
|
||||
|
||||
-- Place the node!
|
||||
local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir)
|
||||
if not success then
|
||||
return itemstack
|
||||
end
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
sign_info = mcl_signs.signtext_info_standing[rotation_level + 1]
|
||||
-- Side
|
||||
else
|
||||
-- Wall sign
|
||||
local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir)
|
||||
if not success then
|
||||
return itemstack
|
||||
end
|
||||
sign_info = mcl_signs.signtext_info_wall[fdir + 1]
|
||||
end
|
||||
|
||||
-- Determine spawn position of entity
|
||||
local place_pos
|
||||
if minetest.registered_nodes[node_under.name].buildable_to then
|
||||
place_pos = under
|
||||
else
|
||||
place_pos = above
|
||||
end
|
||||
|
||||
if DEBUG then
|
||||
minetest.log("action", "[mcl_signs] Register_Sign::Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info))
|
||||
end
|
||||
|
||||
local text_entity = minetest.add_entity({
|
||||
x = place_pos.x + sign_info.delta.x,
|
||||
y = place_pos.y + sign_info.delta.y,
|
||||
z = place_pos.z + sign_info.delta.z }, "mcl_signs:text")
|
||||
text_entity:set_yaw(sign_info.yaw)
|
||||
text_entity:get_luaentity()._signnodename = nodeitem:get_name()
|
||||
|
||||
minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true)
|
||||
|
||||
mcl_signs:show_formspec(placer, place_pos)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign)
|
||||
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
||||
|
||||
-- debug step
|
||||
if DEBUG then
|
||||
minetest.log("action", "[mcl_signs] Registered: mcl_signs:wall_sign" .. _name .. color .. "\n" .. dump(new_sign))
|
||||
minetest.log("action", "[mcl_signs] mcl_signs:wall_sign_standard\n" .. dump(mcl_signs.wall_standard))
|
||||
end
|
||||
|
||||
-- standing sign base.
|
||||
local new_sign_standing = {}
|
||||
new_sign_standing = table.copy(mcl_signs.standing_standard)
|
||||
new_sign_standing.drop = "mcl_signs:wall_sign" .. _name
|
||||
new_sign_standing.wield_image = "(default_sign.png^[multiply:" .. color .. ")"
|
||||
new_sign_standing.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" }
|
||||
new_sign_standing.inventory_image = "(default_sign.png^[multiply:" .. color .. ")"
|
||||
minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
||||
-- debug step
|
||||
if DEBUG then
|
||||
minetest.log("action", "[mcl_signs] Registered: mcl_signs:standing_sign" .. _name .. color .. "\n" .. dump(new_sign_standing))
|
||||
end
|
||||
|
||||
-- 22.5°
|
||||
local ssign22_5d = table.copy(new_sign_standing)
|
||||
ssign22_5d.mesh = "mcl_signs_sign22.5.obj"
|
||||
ssign22_5d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign45" .. _name
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
||||
|
||||
-- 45°
|
||||
local ssign45d = table.copy(new_sign_standing)
|
||||
ssign45d.mesh = "mcl_signs_sign45.obj"
|
||||
ssign45d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign67_5" .. _name
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
||||
|
||||
-- 67.5°
|
||||
local ssign67_5d = table.copy(new_sign_standing)
|
||||
ssign67_5d.mesh = "mcl_signs_sign67.5.obj"
|
||||
ssign67_5d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign" .. _name
|
||||
node.param2 = (node.param2 + 1) % 4
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
||||
|
||||
-- register Doc entry
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name)
|
||||
end
|
||||
|
||||
--register standing sign's rotation_levels
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1})
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2})
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3})
|
||||
end
|
||||
|
||||
--- The same as reregister_sign, except caller defines the textures. Note, there is a greyscale version of the sign,
|
||||
--- called "default_sign_greyscale.png" and "mcl_signs_sign_greyscale.png" for optional use in the textures directory.
|
||||
---
|
||||
--- modname: optional (pass "" or "false" to ignore), for use with other mods to
|
||||
--- allow the creation of a sign from the mod's wood (if installed).
|
||||
---
|
||||
--- _name: the sign's name suffix, such as "_dark" or "_red", etc., appended to "wall_sign" or "standing_sign"
|
||||
---
|
||||
--- tiles: the texture file to use for the sign.
|
||||
---
|
||||
--- color: color the texture file to use with this color. Use white (#FFFFFF) to negate the color,
|
||||
--- and just use the texture as is
|
||||
---
|
||||
--- inventory_image: the texture file to use for the sign's display in inventory.
|
||||
---
|
||||
--- wield_image: the texture file to use for the sign's weilded (in hand) object.
|
||||
---
|
||||
--- inventory_image: the image used for in-inventory and in hand.
|
||||
---
|
||||
--- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign.
|
||||
--- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign"
|
||||
function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, inventory_image, wield_image, ttsign)
|
||||
local mod_name_pass = false
|
||||
if modname ~= "" and modname ~= "false" then
|
||||
if minetest.get_modpath(modname) then
|
||||
mod_name_pass = true
|
||||
end
|
||||
if mod_name_pass == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
local new_sign = {}
|
||||
|
||||
new_sign = table.copy(mcl_signs.wall_standard)
|
||||
|
||||
new_sign.wield_image ="("..wield_image.."^[multiply:" .. color .. ")"
|
||||
new_sign.tiles = { "("..tiles.."^[multiply:" .. color .. ")" }
|
||||
new_sign.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")"
|
||||
new_sign.description = S(ttsign)
|
||||
-- currently have to do this, because of how the base node placement works.
|
||||
new_sign.on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node_under = minetest.get_node(under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then
|
||||
return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
local dir = vector.subtract(under, above)
|
||||
|
||||
-- Only build when it's legal
|
||||
local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name]
|
||||
if not abovenodedef or abovenodedef.buildable_to == false then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(dir)
|
||||
local fdir = minetest.dir_to_facedir(dir)
|
||||
|
||||
local sign_info
|
||||
local nodeitem = ItemStack(itemstack)
|
||||
-- Ceiling
|
||||
if wdir == 0 then
|
||||
--how would you add sign to ceiling?
|
||||
return itemstack
|
||||
-- Floor
|
||||
elseif wdir == 1 then
|
||||
-- Standing sign
|
||||
|
||||
-- Determine the sign rotation based on player's yaw
|
||||
local yaw = pi * 2 - placer:get_look_horizontal()
|
||||
|
||||
-- Select one of 16 possible rotations (0-15)
|
||||
local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16)
|
||||
|
||||
if rotation_level > 15 then
|
||||
rotation_level = 0
|
||||
elseif rotation_level < 0 then
|
||||
rotation_level = 15
|
||||
end
|
||||
|
||||
-- The actual rotation is a combination of predefined mesh and facedir (see node definition)
|
||||
if rotation_level % 4 == 0 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign" .. _name)
|
||||
elseif rotation_level % 4 == 1 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name)
|
||||
elseif rotation_level % 4 == 2 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign45" .. _name)
|
||||
elseif rotation_level % 4 == 3 then
|
||||
nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name)
|
||||
end
|
||||
fdir = math.floor(rotation_level / 4)
|
||||
|
||||
-- Place the node!
|
||||
local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir)
|
||||
if not success then
|
||||
return itemstack
|
||||
end
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
sign_info = mcl_signs.signtext_info_standing[rotation_level + 1]
|
||||
-- Side
|
||||
else
|
||||
-- Wall sign
|
||||
local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir)
|
||||
if not success then
|
||||
return itemstack
|
||||
end
|
||||
sign_info = mcl_signs.signtext_info_wall[fdir + 1]
|
||||
end
|
||||
|
||||
-- Determine spawn position of entity
|
||||
local place_pos
|
||||
if minetest.registered_nodes[node_under.name].buildable_to then
|
||||
place_pos = under
|
||||
else
|
||||
place_pos = above
|
||||
end
|
||||
|
||||
local text_entity = minetest.add_entity({
|
||||
x = place_pos.x + sign_info.delta.x,
|
||||
y = place_pos.y + sign_info.delta.y,
|
||||
z = place_pos.z + sign_info.delta.z }, "mcl_signs:text")
|
||||
text_entity:set_yaw(sign_info.yaw)
|
||||
text_entity:get_luaentity()._signnodename = nodeitem:get_name()
|
||||
|
||||
minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true)
|
||||
|
||||
mcl_signs:show_formspec(placer, place_pos)
|
||||
return itemstack
|
||||
end
|
||||
minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign)
|
||||
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
||||
|
||||
-- standing sign base.
|
||||
local new_sign_standing = {}
|
||||
new_sign_standing = table.copy(mcl_signs.standing_standard)
|
||||
new_sign_standing.drop = "mcl_signs:wall_sign" .. _name
|
||||
new_sign_standing.wield_image ="("..wield_image.."^[multiply:" .. color .. ")"
|
||||
new_sign_standing.tiles = { "("..tiles.."^[multiply:" .. color .. ")" }
|
||||
new_sign_standing.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")"
|
||||
minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
||||
|
||||
-- 22.5°
|
||||
local ssign22_5d = table.copy(new_sign_standing)
|
||||
ssign22_5d.mesh = "mcl_signs_sign22.5.obj"
|
||||
ssign22_5d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign45" .. _name
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
||||
|
||||
-- 45°
|
||||
local ssign45d = table.copy(new_sign_standing)
|
||||
ssign45d.mesh = "mcl_signs_sign45.obj"
|
||||
ssign45d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign67_5" .. _name
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
||||
|
||||
-- 67.5°
|
||||
local ssign67_5d = table.copy(new_sign_standing)
|
||||
ssign67_5d.mesh = "mcl_signs_sign67.5.obj"
|
||||
ssign67_5d.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign" .. _name
|
||||
node.param2 = (node.param2 + 1) % 4
|
||||
minetest.swap_node(pos, node)
|
||||
elseif mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
end
|
||||
minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
||||
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
||||
|
||||
-- register Doc entry
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name)
|
||||
doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name)
|
||||
end
|
||||
|
||||
--register standing sign's rotation_levels
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1})
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2})
|
||||
table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3})
|
||||
|
||||
end
|
||||
|
||||
--- Usage: Call this with the mod's name, the wood's item string (for the planks), and with the sign's suffix.
|
||||
--- Registers the crafting recipe for that sign. for every registered sign, call this function to register the
|
||||
--- standard recipe for the sign. Otherwise, you have to do your own register craft call.
|
||||
|
@ -1037,7 +1472,7 @@ local function get_rotation_level(facedir, nodename)
|
|||
end
|
||||
end
|
||||
rl = facedir * 4 + offset
|
||||
if 1 == 1 then
|
||||
if DEBUG then
|
||||
minetest.log("action", "[mcl_signs] GetRotationLevel: NodeName: " .. nodename .. " RL value: " .. rl)
|
||||
end
|
||||
return rl
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 5.2 KiB |
Loading…
Reference in a new issue