forked from VoxeLibre/VoxeLibre
Merge pull request 'fix frames and signs to reset after /clearobjects' (#2919) from fix_clearobjs_signs_frames into master
Reviewed-on: MineClone2/MineClone2#2919 Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
d5b5d80a1a
|
@ -34,6 +34,8 @@ local glow_amount = 6 -- LIGHT_MAX is 15, but the items aren't supposed to be a
|
||||||
local frame_item_base = {}
|
local frame_item_base = {}
|
||||||
local map_item_base = {}
|
local map_item_base = {}
|
||||||
|
|
||||||
|
local TIMER_INTERVAL = 40.0
|
||||||
|
|
||||||
-- Time to Fleckenstein! (it just sounds cool lol)
|
-- Time to Fleckenstein! (it just sounds cool lol)
|
||||||
|
|
||||||
--- self: the object to roll.
|
--- self: the object to roll.
|
||||||
|
@ -247,6 +249,7 @@ mcl_itemframes.update_item_entity = function(pos, node, param2)
|
||||||
local map_id_entity = {}
|
local map_id_entity = {}
|
||||||
local map_id_lua = {}
|
local map_id_lua = {}
|
||||||
|
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
if map_id == "" then
|
if map_id == "" then
|
||||||
-- handle regular items placed into custom frame.
|
-- handle regular items placed into custom frame.
|
||||||
if mcl_itemframes.DEBUG then
|
if mcl_itemframes.DEBUG then
|
||||||
|
@ -268,13 +271,32 @@ mcl_itemframes.update_item_entity = function(pos, node, param2)
|
||||||
if itemname == "" or itemname == nil then
|
if itemname == "" or itemname == nil then
|
||||||
map_id_lua._texture = "blank.png"
|
map_id_lua._texture = "blank.png"
|
||||||
map_id_lua._scale = 1
|
map_id_lua._scale = 1
|
||||||
|
|
||||||
|
-- set up glow, as this is the default/initial clause on placement.
|
||||||
if has_glow then
|
if has_glow then
|
||||||
map_id_lua.glow = glow_amount
|
map_id_lua.glow = glow_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if there's nothing to display, then kill the timer.
|
||||||
|
if timer:is_started() == true then
|
||||||
|
timer:stop()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
map_id_lua._texture = itemname
|
map_id_lua._texture = itemname
|
||||||
local def = minetest.registered_items[itemname]
|
local def = minetest.registered_items[itemname]
|
||||||
map_id_lua._scale = def and def.wield_scale and def.wield_scale.x or 1
|
map_id_lua._scale = def and def.wield_scale and def.wield_scale.x or 1
|
||||||
|
|
||||||
|
-- fix for /ClearObjects
|
||||||
|
if minetest.get_item_group(itemname, "clock") == 0 then
|
||||||
|
-- Do timer related stuff - but only if there is something to display... and it's not a clock.
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
else
|
||||||
|
timer:stop()
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
if mcl_itemframes.DEBUG then
|
if mcl_itemframes.DEBUG then
|
||||||
minetest.log("action", "[mcl_itemframes] Update_Generic_Item: item's name: " .. itemname)
|
minetest.log("action", "[mcl_itemframes] Update_Generic_Item: item's name: " .. itemname)
|
||||||
|
@ -297,6 +319,15 @@ mcl_itemframes.update_item_entity = function(pos, node, param2)
|
||||||
else
|
else
|
||||||
minetest.log("error", "[mcl_itemframes] Update_Generic_Item: Failed to set Map Item in " .. found_name_to_use .. "'s frame.")
|
minetest.log("error", "[mcl_itemframes] Update_Generic_Item: Failed to set Map Item in " .. found_name_to_use .. "'s frame.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- give maps a refresh timer.
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
else
|
||||||
|
timer:stop()
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- finally, set the rotation (roll) of the displayed object.
|
-- finally, set the rotation (roll) of the displayed object.
|
||||||
|
@ -364,7 +395,7 @@ function mcl_itemframes.create_base_item_entity()
|
||||||
textures = { "blank.png" },
|
textures = { "blank.png" },
|
||||||
_texture = "blank.png",
|
_texture = "blank.png",
|
||||||
_scale = 1,
|
_scale = 1,
|
||||||
|
groups = { immortal = 1, },
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
if staticdata and staticdata ~= "" then
|
if staticdata and staticdata ~= "" then
|
||||||
local data = staticdata:split(";")
|
local data = staticdata:split(";")
|
||||||
|
@ -395,7 +426,7 @@ function mcl_itemframes.create_base_item_entity()
|
||||||
end
|
end
|
||||||
return ""
|
return ""
|
||||||
end,
|
end,
|
||||||
|
on_punch = function() return true end,
|
||||||
_update_texture = function(self)
|
_update_texture = function(self)
|
||||||
if self._texture then
|
if self._texture then
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
|
@ -561,6 +592,23 @@ function mcl_itemframes.custom_register_lbm()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function register_frame_achievements()
|
||||||
|
|
||||||
|
awards.register_achievement("mcl_itemframes:glowframe", {
|
||||||
|
title = S("Glow and Behold!"),
|
||||||
|
description = S("Craft a glow item frame."),
|
||||||
|
icon = "mcl_itemframes_glow_item_frame.png",
|
||||||
|
trigger = {
|
||||||
|
type = "craft",
|
||||||
|
item = "mcl_itemframes:glow_item_frame",
|
||||||
|
target = 1
|
||||||
|
},
|
||||||
|
type = "Advancement",
|
||||||
|
group = "Overworld",
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function mcl_itemframes.create_base_definitions()
|
function mcl_itemframes.create_base_definitions()
|
||||||
if mcl_itemframes.DEBUG then
|
if mcl_itemframes.DEBUG then
|
||||||
minetest.log("action", "[mcl_itemframes] create_base_definitions.")
|
minetest.log("action", "[mcl_itemframes] create_base_definitions.")
|
||||||
|
@ -590,7 +638,7 @@ function mcl_itemframes.create_base_definitions()
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 7, attached_node_facedir = 1 },
|
groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 7, }, -- attached_node_facedir = 1 }, -- allows for more placement options.
|
||||||
sounds = mcl_sounds.node_sound_defaults(),
|
sounds = mcl_sounds.node_sound_defaults(),
|
||||||
node_placement_prediction = "",
|
node_placement_prediction = "",
|
||||||
|
|
||||||
|
@ -598,16 +646,19 @@ function mcl_itemframes.create_base_definitions()
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
local stack = inv:get_stack("main", 1)
|
local stack = inv:get_stack("main", 1)
|
||||||
local itemname = stack:get_name()
|
local itemname = stack:get_name()
|
||||||
|
local node = {}
|
||||||
if minetest.get_item_group(itemname, "clock") > 0 then
|
if minetest.get_item_group(itemname, "clock") > 0 then
|
||||||
local new_name = "mcl_clock:clock_" .. (mcl_worlds.clock_works(pos) and mcl_clock.old_time or mcl_clock.random_frame)
|
local new_name = "mcl_clock:clock_" .. (mcl_worlds.clock_works(pos) and mcl_clock.old_time or mcl_clock.random_frame)
|
||||||
if itemname ~= new_name then
|
if itemname ~= new_name then
|
||||||
stack:set_name(new_name)
|
stack:set_name(new_name)
|
||||||
inv:set_stack("main", 1, stack)
|
inv:set_stack("main", 1, stack)
|
||||||
local node = minetest.get_node(pos)
|
node = minetest.get_node(pos)
|
||||||
mcl_itemframes.update_item_entity(pos, node, node.param2)
|
mcl_itemframes.update_item_entity(pos, node, node.param2)
|
||||||
|
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(1.0)
|
minetest.get_node_timer(pos):start(1.0)
|
||||||
|
else
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
mcl_itemframes.update_item_entity(pos, node, node.param2)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -616,6 +667,14 @@ function mcl_itemframes.create_base_definitions()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local dir = vector.subtract(pointed_thing.under, pointed_thing.above)
|
||||||
|
local wdir = minetest.dir_to_wallmounted(dir)
|
||||||
|
|
||||||
|
-- remove bottom and top of objects.
|
||||||
|
if wdir == 0 or wdir == 1 then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
-- Use pointed node's on_rightclick function first, if present
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
if placer and not placer:get_player_control().sneak then
|
if placer and not placer:get_player_control().sneak then
|
||||||
|
@ -784,15 +843,11 @@ function mcl_itemframes.create_base_definitions()
|
||||||
mcl_itemframes.glow_frame_base.inventory_image = "mcl_itemframes_glow_item_frame_item.png"
|
mcl_itemframes.glow_frame_base.inventory_image = "mcl_itemframes_glow_item_frame_item.png"
|
||||||
mcl_itemframes.glow_frame_base.wield_image = "mcl_itemframes_glow_item_frame.png"
|
mcl_itemframes.glow_frame_base.wield_image = "mcl_itemframes_glow_item_frame.png"
|
||||||
mcl_itemframes.glow_frame_base.mesh = "mcl_itemframes_glow_item_frame.obj"
|
mcl_itemframes.glow_frame_base.mesh = "mcl_itemframes_glow_item_frame.obj"
|
||||||
|
mcl_itemframes.glow_frame_base.glow = 1 --make the glow frames have some glow at night, but not enough to be a light source.
|
||||||
|
|
||||||
--[[
|
-- set up the achievement for glow frames.
|
||||||
minetest.register_node("mcl_itemframes:glow_item_frame", mcl_itemframes.glow_frame_base)
|
register_frame_achievements()
|
||||||
|
|
||||||
mcl_itemframes.update_frame_registry("false", "mcl_itemframes:item_frame", false)
|
|
||||||
mcl_itemframes.update_frame_registry("false", "mcl_itemframes:glow_item_frame", true)
|
|
||||||
create_register_lbm("mcl_itemframes:item_frame")
|
|
||||||
create_register_lbm("mcl_itemframes:glow_item_frame")
|
|
||||||
--]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- for compatibility:
|
-- for compatibility:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
---
|
---
|
||||||
# Mineclone2-Signs
|
# Mineclone2-Signs
|
||||||
---
|
---
|
||||||
A reworking of MineClone 2's mcl_signs to be colorable and made to glow. Rquires Minetest and Mineclone2.
|
A reworking of MineClone 2's mcl_signs to be colorable and made to glow. Requires Minetest and Mineclone2.
|
||||||
---
|
---
|
||||||
|
|
||||||
Created by Michieal (FaerRaven) @ DateTime: 10/14/22 4:05 PM
|
Created by Michieal (FaerRaven) @ DateTime: 10/14/22 4:05 PM
|
||||||
|
|
|
@ -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")
|
||||||
|
@ -29,7 +28,11 @@ local NUMBER_OF_LINES = 4
|
||||||
|
|
||||||
local LINE_HEIGHT = 14
|
local LINE_HEIGHT = 14
|
||||||
local CHAR_WIDTH = 5
|
local CHAR_WIDTH = 5
|
||||||
|
local TIMER_INTERVAL = 40.0
|
||||||
-- -----------------------
|
-- -----------------------
|
||||||
|
-- CACHE LOCAL COPIES
|
||||||
|
local table = table
|
||||||
|
local string = string
|
||||||
|
|
||||||
-- CACHE NODE_SOUNDS
|
-- CACHE NODE_SOUNDS
|
||||||
local node_sounds
|
local node_sounds
|
||||||
|
@ -161,6 +164,13 @@ 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)
|
||||||
|
-- note: update_sign decides to keep the timer running based on if there is text.
|
||||||
|
-- This prevents every sign from having a timer, when not needed.
|
||||||
|
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
|
||||||
|
@ -272,9 +282,6 @@ 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
|
|
||||||
mcl_signs:destruct_sign(pos)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, node, user, mode)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
|
@ -372,12 +379,15 @@ 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
|
|
||||||
mcl_signs:destruct_sign(pos)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, node, user, mode)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
|
@ -572,16 +582,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 +663,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 +691,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 +711,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 +727,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 +744,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
|
||||||
|
@ -883,7 +898,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 +918,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 +934,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 +950,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 +967,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
|
||||||
|
@ -1450,7 +1465,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 +1477,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 +1488,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
|
||||||
|
@ -1762,7 +1819,7 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
||||||
if not meta then
|
if not meta then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local text = meta:get_string("text")
|
local text = meta:get_string("text", "")
|
||||||
if fields and (text == "" and fields.text) then
|
if fields and (text == "" and fields.text) then
|
||||||
meta:set_string("text", fields.text)
|
meta:set_string("text", fields.text)
|
||||||
text = fields.text
|
text = fields.text
|
||||||
|
@ -1843,19 +1900,8 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
|
||||||
local text_entity
|
local text_entity
|
||||||
for _, v in ipairs(objects) do
|
text_entity = mcl_signs:get_text_entity(pos,force_remove)
|
||||||
local ent = v:get_luaentity()
|
|
||||||
if ent and ent.name == "mcl_signs:text" then
|
|
||||||
if force_remove then
|
|
||||||
v:remove()
|
|
||||||
else
|
|
||||||
text_entity = v
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not text_entity then
|
if not text_entity then
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
|
@ -1904,6 +1950,24 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
||||||
|
|
||||||
-- save sign metadata.
|
-- save sign metadata.
|
||||||
meta:set_string("mcl_signs:text_color", text_color)
|
meta:set_string("mcl_signs:text_color", text_color)
|
||||||
|
|
||||||
|
-- Moved timer stuff to here, to make sure that it's called and only has one set of code.
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
if text_entity and text ~= "" then
|
||||||
|
-- Do timer related stuff - but only if there is text to display.
|
||||||
|
-- Also, prevent excessive use with punching. (see node def.)
|
||||||
|
if timer:is_started() == false then
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
else
|
||||||
|
timer:stop()
|
||||||
|
timer:start(TIMER_INTERVAL)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if timer:is_started() == true then
|
||||||
|
timer:stop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- debug step
|
-- debug step
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
minetest.log("action", "[mcl_signs] Update_Sign: Post-Sign Update: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos))
|
minetest.log("action", "[mcl_signs] Update_Sign: Post-Sign Update: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos))
|
||||||
|
@ -1920,3 +1984,20 @@ function mcl_signs:show_formspec(player, pos)
|
||||||
"size[6,3]textarea[0.25,0.25;6,1.5;text;" .. F(S("Enter sign text:")) .. ";]label[0,1.5;" .. F(S("Maximum line length: 15")) .. "\n" .. F(S("Maximum lines: 4")) .. "]button_exit[0,2.5;6,1;submit;" .. F(S("Done")) .. "]"
|
"size[6,3]textarea[0.25,0.25;6,1.5;text;" .. F(S("Enter sign text:")) .. ";]label[0,1.5;" .. F(S("Maximum line length: 15")) .. "\n" .. F(S("Maximum lines: 4")) .. "]button_exit[0,2.5;6,1;submit;" .. F(S("Done")) .. "]"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_signs:get_text_entity (pos, force_remove)
|
||||||
|
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
local text_entity = false -- just to have a check for failure.
|
||||||
|
for _, v in ipairs(objects) do
|
||||||
|
local ent = v:get_luaentity()
|
||||||
|
if ent and ent.name == "mcl_signs:text" then
|
||||||
|
if force_remove ~= nil and force_remove == true then
|
||||||
|
v:remove()
|
||||||
|
else
|
||||||
|
text_entity = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return text_entity
|
||||||
|
end
|
Loading…
Reference in New Issue