fix signs to reset after /clearobjects
Additionally, added in the register_hanging_sing_craft() for future use.
This commit is contained in:
parent
10a3a022b6
commit
e67c6e1ada
|
@ -7,7 +7,6 @@
|
||||||
--local logging = minetest.settings:get_bool("mcl_logging_mcl_signs",true)
|
--local logging = minetest.settings:get_bool("mcl_logging_mcl_signs",true)
|
||||||
|
|
||||||
local DEBUG = minetest.settings:get_bool("mcl_logging_mcl_signs", false) -- special debug setting.
|
local DEBUG = minetest.settings:get_bool("mcl_logging_mcl_signs", false) -- special debug setting.
|
||||||
local table = table -- copied from the original signs init file.
|
|
||||||
|
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
minetest.log("action", "[mcl_signs] Signs API Loading")
|
minetest.log("action", "[mcl_signs] Signs API Loading")
|
||||||
|
@ -30,6 +29,9 @@ local NUMBER_OF_LINES = 4
|
||||||
local LINE_HEIGHT = 14
|
local LINE_HEIGHT = 14
|
||||||
local CHAR_WIDTH = 5
|
local CHAR_WIDTH = 5
|
||||||
-- -----------------------
|
-- -----------------------
|
||||||
|
-- CACHE LOCAL COPIES
|
||||||
|
local table = table
|
||||||
|
local string = string
|
||||||
|
|
||||||
-- CACHE NODE_SOUNDS
|
-- CACHE NODE_SOUNDS
|
||||||
local node_sounds
|
local node_sounds
|
||||||
|
@ -161,10 +163,21 @@ mcl_signs.wall_standard = {
|
||||||
stack_max = 16,
|
stack_max = 16,
|
||||||
sounds = node_sounds,
|
sounds = node_sounds,
|
||||||
|
|
||||||
|
on_timer = function(pos)
|
||||||
|
-- fix for /ClearObjects
|
||||||
|
mcl_signs:update_sign(pos)
|
||||||
|
minetest.get_node_timer(pos):start(40.0)
|
||||||
|
end,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
-- Use pointed node's on_rightclick function first, if present
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
local node_under = minetest.get_node(under)
|
local node_under = minetest.get_node(under)
|
||||||
if placer and not placer:get_player_control().sneak then
|
if placer and not placer:get_player_control().sneak then
|
||||||
|
@ -272,8 +285,9 @@ mcl_signs.wall_standard = {
|
||||||
-- Not Useless Code. force updates the sign.
|
-- Not Useless Code. force updates the sign.
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
mcl_signs:update_sign(pos)
|
mcl_signs:update_sign(pos)
|
||||||
if DISINTEGRATE then
|
local timer = minetest.get_node_timer(pos)
|
||||||
mcl_signs:destruct_sign(pos)
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, node, user, mode)
|
||||||
|
@ -297,6 +311,11 @@ mcl_signs.wall_standard = {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local iname = item:get_name()
|
local iname = item:get_name()
|
||||||
|
|
||||||
|
@ -372,11 +391,18 @@ mcl_signs.standing_standard = {
|
||||||
mcl_signs:destruct_sign(pos)
|
mcl_signs:destruct_sign(pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
on_timer = function(pos)
|
||||||
|
-- fix for /ClearObjects
|
||||||
|
mcl_signs:update_sign(pos)
|
||||||
|
minetest.get_node_timer(pos):start(40.0)
|
||||||
|
end,
|
||||||
|
|
||||||
-- Not Useless Code. this force updates the sign.
|
-- Not Useless Code. this force updates the sign.
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
mcl_signs:update_sign(pos)
|
mcl_signs:update_sign(pos)
|
||||||
if DISINTEGRATE then
|
local timer = minetest.get_node_timer(pos)
|
||||||
mcl_signs:destruct_sign(pos)
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, node, user, mode)
|
||||||
|
@ -401,6 +427,11 @@ mcl_signs.standing_standard = {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local iname = item:get_name()
|
local iname = item:get_name()
|
||||||
|
|
||||||
|
@ -559,6 +590,11 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local dir = vector.subtract(under, above)
|
local dir = vector.subtract(under, above)
|
||||||
|
|
||||||
-- Only build when it's legal
|
-- Only build when it's legal
|
||||||
|
@ -572,16 +608,21 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
|
|
||||||
local sign_info
|
local sign_info
|
||||||
local nodeitem = ItemStack(itemstack)
|
local nodeitem = ItemStack(itemstack)
|
||||||
|
|
||||||
|
local yaw = 0
|
||||||
|
|
||||||
-- Ceiling
|
-- Ceiling
|
||||||
if wdir == 0 then
|
if wdir == 0 then
|
||||||
--how would you add sign to ceiling?
|
--how would you add sign to ceiling? simple - hanging sign.
|
||||||
|
-- add code for placement underneath a node.
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
-- Floor
|
-- Floor
|
||||||
elseif wdir == 1 then
|
elseif wdir == 1 then
|
||||||
-- Standing sign
|
-- Standing sign
|
||||||
|
|
||||||
-- Determine the sign rotation based on player's yaw
|
-- Determine the sign rotation based on player's yaw
|
||||||
local yaw = pi * 2 - placer:get_look_horizontal()
|
yaw = pi * 2 - placer:get_look_horizontal()
|
||||||
|
|
||||||
-- Select one of 16 possible rotations (0-15)
|
-- Select one of 16 possible rotations (0-15)
|
||||||
local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16)
|
local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16)
|
||||||
|
@ -648,7 +689,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_signs:wall_sign" .. _name, new_sign)
|
minetest.register_node(":mcl_signs:wall_sign" .. _name, new_sign)
|
||||||
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
||||||
|
|
||||||
-- debug step
|
-- debug step
|
||||||
|
@ -676,7 +717,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
minetest.register_node("mcl_signs:standing_sign" .. _name, new_sign_standing)
|
minetest.register_node(":mcl_signs:standing_sign" .. _name, new_sign_standing)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
||||||
-- debug step
|
-- debug step
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
|
@ -696,7 +737,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
minetest.register_node(":mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
||||||
|
|
||||||
-- 45°
|
-- 45°
|
||||||
|
@ -712,7 +753,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign45" .. _name, ssign45d)
|
minetest.register_node(":mcl_signs:standing_sign45" .. _name, ssign45d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
||||||
|
|
||||||
-- 67.5°
|
-- 67.5°
|
||||||
|
@ -729,7 +770,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
minetest.register_node(":mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
||||||
|
|
||||||
-- register Doc entry
|
-- register Doc entry
|
||||||
|
@ -799,6 +840,11 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local dir = vector.subtract(under, above)
|
local dir = vector.subtract(under, above)
|
||||||
|
|
||||||
-- Only build when it's legal
|
-- Only build when it's legal
|
||||||
|
@ -883,7 +929,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
mcl_signs:show_formspec(placer, place_pos)
|
mcl_signs:show_formspec(placer, place_pos)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:wall_sign" .. _name, new_sign)
|
minetest.register_node(":mcl_signs:wall_sign" .. _name, new_sign)
|
||||||
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
update_sign_registry("wall", "mcl_signs:wall_sign" .. _name)
|
||||||
|
|
||||||
-- standing sign base.
|
-- standing sign base.
|
||||||
|
@ -903,7 +949,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
minetest.register_node("mcl_signs:standing_sign" .. _name, new_sign_standing)
|
minetest.register_node(":mcl_signs:standing_sign" .. _name, new_sign_standing)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign" .. _name)
|
||||||
|
|
||||||
-- 22.5°
|
-- 22.5°
|
||||||
|
@ -919,7 +965,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
minetest.register_node(":mcl_signs:standing_sign22_5" .. _name, ssign22_5d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name)
|
||||||
|
|
||||||
-- 45°
|
-- 45°
|
||||||
|
@ -935,7 +981,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign45" .. _name, ssign45d)
|
minetest.register_node(":mcl_signs:standing_sign45" .. _name, ssign45d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name)
|
||||||
|
|
||||||
-- 67.5°
|
-- 67.5°
|
||||||
|
@ -952,7 +998,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
||||||
mcl_signs:update_sign(pos, nil, nil, true)
|
mcl_signs:update_sign(pos, nil, nil, true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.register_node("mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
minetest.register_node(":mcl_signs:standing_sign67_5" .. _name, ssign67_5d)
|
||||||
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name)
|
||||||
|
|
||||||
-- register Doc entry
|
-- register Doc entry
|
||||||
|
@ -1017,6 +1063,11 @@ function mcl_signs.reregister_sign (modname, color, _name, ttsign)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local dir = vector.subtract(under, above)
|
local dir = vector.subtract(under, above)
|
||||||
|
|
||||||
-- Only build when it's legal
|
-- Only build when it's legal
|
||||||
|
@ -1255,6 +1306,11 @@ function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, invento
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(40.0)
|
||||||
|
end
|
||||||
|
|
||||||
local dir = vector.subtract(under, above)
|
local dir = vector.subtract(under, above)
|
||||||
|
|
||||||
-- Only build when it's legal
|
-- Only build when it's legal
|
||||||
|
@ -1450,7 +1506,7 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mcl_signs:wall_sign" .. _name,
|
recipe = ":mcl_signs:wall_sign" .. _name,
|
||||||
burntime = 10,
|
burntime = 10,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1462,7 +1518,7 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
||||||
-- register crafts (actual recipe)
|
-- register crafts (actual recipe)
|
||||||
if minetest.get_modpath(modname) then
|
if minetest.get_modpath(modname) then
|
||||||
|
|
||||||
local itemstring = "mcl_signs:wall_sign"
|
local itemstring = ":mcl_signs:wall_sign"
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = itemstring .. _name .. " 3",
|
output = itemstring .. _name .. " 3",
|
||||||
|
@ -1473,7 +1529,49 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_signs.register_hanging_sign_craft(modname, wood_item_string, _name)
|
||||||
|
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
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "fuel",
|
||||||
|
recipe = ":mcl_signs:wall_sign" .. _name,
|
||||||
|
burntime = 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- debug step
|
||||||
|
if DEBUG then
|
||||||
|
minetest.log("action", "[mcl_signs] Register Sign Crafts: \n" .. modname .. "\n" .. wood_item_string .. "\n" .. _name)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- register crafts (actual recipe)
|
||||||
|
if minetest.get_modpath(modname) then
|
||||||
|
|
||||||
|
local itemstring = ":mcl_signs:hanging_sign"
|
||||||
|
local quantity = "6"
|
||||||
|
|
||||||
|
local bamboo = string.find(wood_item_string, "bamboo")
|
||||||
|
if bamboo then
|
||||||
|
quantity = "2"
|
||||||
|
end
|
||||||
|
minetest.register_craft({
|
||||||
|
output = itemstring .. _name .. " " .. quantity,
|
||||||
|
recipe = {
|
||||||
|
{ "mcl_lanterns:chain", "", "mcl_lanterns:chain" },
|
||||||
|
{ wood_item_string, wood_item_string, wood_item_string },
|
||||||
|
{ wood_item_string, wood_item_string, wood_item_string },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user