Merge pull request 'fix frames and signs to reset after /clearobjects' (#2919) from fix_clearobjs_signs_frames into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2919 Reviewed-by: cora <cora@noreply.git.minetest.land>mcl-craftguide-drop-sfinv
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 map_item_base = {}
|
||||
|
||||
local TIMER_INTERVAL = 40.0
|
||||
|
||||
-- Time to Fleckenstein! (it just sounds cool lol)
|
||||
|
||||
--- 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_lua = {}
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if map_id == "" then
|
||||
-- handle regular items placed into custom frame.
|
||||
if mcl_itemframes.DEBUG then
|
||||
|
@ -268,13 +271,32 @@ mcl_itemframes.update_item_entity = function(pos, node, param2)
|
|||
if itemname == "" or itemname == nil then
|
||||
map_id_lua._texture = "blank.png"
|
||||
map_id_lua._scale = 1
|
||||
|
||||
-- set up glow, as this is the default/initial clause on placement.
|
||||
if has_glow then
|
||||
map_id_lua.glow = glow_amount
|
||||
end
|
||||
|
||||
-- if there's nothing to display, then kill the timer.
|
||||
if timer:is_started() == true then
|
||||
timer:stop()
|
||||
end
|
||||
else
|
||||
map_id_lua._texture = itemname
|
||||
local def = minetest.registered_items[itemname]
|
||||
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
|
||||
if mcl_itemframes.DEBUG then
|
||||
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
|
||||
minetest.log("error", "[mcl_itemframes] Update_Generic_Item: Failed to set Map Item in " .. found_name_to_use .. "'s frame.")
|
||||
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
|
||||
|
||||
-- finally, set the rotation (roll) of the displayed object.
|
||||
|
@ -364,7 +395,7 @@ function mcl_itemframes.create_base_item_entity()
|
|||
textures = { "blank.png" },
|
||||
_texture = "blank.png",
|
||||
_scale = 1,
|
||||
|
||||
groups = { immortal = 1, },
|
||||
on_activate = function(self, staticdata)
|
||||
if staticdata and staticdata ~= "" then
|
||||
local data = staticdata:split(";")
|
||||
|
@ -395,7 +426,7 @@ function mcl_itemframes.create_base_item_entity()
|
|||
end
|
||||
return ""
|
||||
end,
|
||||
|
||||
on_punch = function() return true end,
|
||||
_update_texture = function(self)
|
||||
if self._texture then
|
||||
self.object:set_properties({
|
||||
|
@ -561,6 +592,23 @@ function mcl_itemframes.custom_register_lbm()
|
|||
|
||||
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()
|
||||
if mcl_itemframes.DEBUG then
|
||||
minetest.log("action", "[mcl_itemframes] create_base_definitions.")
|
||||
|
@ -590,7 +638,7 @@ function mcl_itemframes.create_base_definitions()
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
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(),
|
||||
node_placement_prediction = "",
|
||||
|
||||
|
@ -598,16 +646,19 @@ function mcl_itemframes.create_base_definitions()
|
|||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local stack = inv:get_stack("main", 1)
|
||||
local itemname = stack:get_name()
|
||||
local node = {}
|
||||
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)
|
||||
if itemname ~= new_name then
|
||||
stack:set_name(new_name)
|
||||
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)
|
||||
|
||||
end
|
||||
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,
|
||||
|
||||
|
@ -616,6 +667,14 @@ function mcl_itemframes.create_base_definitions()
|
|||
return itemstack
|
||||
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
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
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.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.glow = 1 --make the glow frames have some glow at night, but not enough to be a light source.
|
||||
|
||||
--[[
|
||||
minetest.register_node("mcl_itemframes:glow_item_frame", mcl_itemframes.glow_frame_base)
|
||||
-- set up the achievement for glow frames.
|
||||
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
|
||||
|
||||
-- for compatibility:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
---
|
||||
# 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
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
--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 table = table -- copied from the original signs init file.
|
||||
|
||||
if DEBUG then
|
||||
minetest.log("action", "[mcl_signs] Signs API Loading")
|
||||
|
@ -29,7 +28,11 @@ local NUMBER_OF_LINES = 4
|
|||
|
||||
local LINE_HEIGHT = 14
|
||||
local CHAR_WIDTH = 5
|
||||
local TIMER_INTERVAL = 40.0
|
||||
-- -----------------------
|
||||
-- CACHE LOCAL COPIES
|
||||
local table = table
|
||||
local string = string
|
||||
|
||||
-- CACHE NODE_SOUNDS
|
||||
local node_sounds
|
||||
|
@ -161,6 +164,13 @@ mcl_signs.wall_standard = {
|
|||
stack_max = 16,
|
||||
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)
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
|
@ -272,9 +282,6 @@ mcl_signs.wall_standard = {
|
|||
-- Not Useless Code. force updates the sign.
|
||||
on_punch = function(pos, node, puncher)
|
||||
mcl_signs:update_sign(pos)
|
||||
if DISINTEGRATE then
|
||||
mcl_signs:destruct_sign(pos)
|
||||
end
|
||||
end,
|
||||
on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
|
@ -372,12 +379,15 @@ mcl_signs.standing_standard = {
|
|||
mcl_signs:destruct_sign(pos)
|
||||
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.
|
||||
on_punch = function(pos, node, puncher)
|
||||
mcl_signs:update_sign(pos)
|
||||
if DISINTEGRATE then
|
||||
mcl_signs:destruct_sign(pos)
|
||||
end
|
||||
end,
|
||||
on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
|
@ -499,7 +509,7 @@ function mcl_signs.make_lbm()
|
|||
name = "mcl_signs:respawn_entities",
|
||||
label = "Respawn sign text entities",
|
||||
run_at_every_load = true,
|
||||
nodenames = registered_sign_nodenames ,
|
||||
nodenames = registered_sign_nodenames,
|
||||
action = function(pos, node)
|
||||
mcl_signs:update_sign(pos)
|
||||
end,
|
||||
|
@ -572,16 +582,21 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
|
||||
local sign_info
|
||||
local nodeitem = ItemStack(itemstack)
|
||||
|
||||
local yaw = 0
|
||||
|
||||
-- Ceiling
|
||||
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
|
||||
-- Floor
|
||||
elseif wdir == 1 then
|
||||
-- Standing sign
|
||||
|
||||
-- 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)
|
||||
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
|
||||
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)
|
||||
|
||||
-- debug step
|
||||
|
@ -676,7 +691,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
return true
|
||||
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)
|
||||
-- debug step
|
||||
if DEBUG then
|
||||
|
@ -696,7 +711,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- 45°
|
||||
|
@ -712,7 +727,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- 67.5°
|
||||
|
@ -729,7 +744,7 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- register Doc entry
|
||||
|
@ -742,9 +757,9 @@ function mcl_signs.register_sign (modname, color, _name, ttsign)
|
|||
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})
|
||||
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 register_sign, except caller defines the textures. Note, there is a greyscale version of the sign,
|
||||
|
@ -782,9 +797,9 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
|
||||
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.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)
|
||||
|
@ -883,16 +898,16 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
mcl_signs:show_formspec(placer, place_pos)
|
||||
return itemstack
|
||||
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)
|
||||
|
||||
-- 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 .. ")"
|
||||
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 .. ")"
|
||||
new_sign_standing.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign22_5" .. _name
|
||||
|
@ -903,7 +918,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- 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)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- 45°
|
||||
|
@ -935,7 +950,7 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
mcl_signs:update_sign(pos, nil, nil, true)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- 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)
|
||||
return true
|
||||
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)
|
||||
|
||||
-- register Doc entry
|
||||
|
@ -965,9 +980,9 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory
|
|||
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})
|
||||
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
|
||||
|
||||
|
@ -1198,9 +1213,9 @@ function mcl_signs.reregister_sign (modname, color, _name, ttsign)
|
|||
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})
|
||||
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,
|
||||
|
@ -1238,9 +1253,9 @@ function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, invento
|
|||
|
||||
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.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)
|
||||
|
@ -1346,9 +1361,9 @@ function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, invento
|
|||
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 .. ")"
|
||||
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 .. ")"
|
||||
new_sign_standing.on_rotate = function(pos, node, user, mode)
|
||||
if mode == screwdriver.ROTATE_FACE then
|
||||
node.name = "mcl_signs:standing_sign22_5" .. _name
|
||||
|
@ -1421,9 +1436,9 @@ function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, invento
|
|||
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})
|
||||
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
|
||||
|
||||
|
@ -1450,7 +1465,7 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
|||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "mcl_signs:wall_sign" .. _name,
|
||||
recipe = ":mcl_signs:wall_sign" .. _name,
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
|
@ -1462,7 +1477,7 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
|||
-- register crafts (actual recipe)
|
||||
if minetest.get_modpath(modname) then
|
||||
|
||||
local itemstring = "mcl_signs:wall_sign"
|
||||
local itemstring = ":mcl_signs:wall_sign"
|
||||
|
||||
minetest.register_craft({
|
||||
output = itemstring .. _name .. " 3",
|
||||
|
@ -1473,7 +1488,49 @@ function mcl_signs.register_sign_craft(modname, wood_item_string, _name)
|
|||
},
|
||||
})
|
||||
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
|
||||
|
||||
-- Helper functions
|
||||
|
@ -1762,7 +1819,7 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
|||
if not meta then
|
||||
return false
|
||||
end
|
||||
local text = meta:get_string("text")
|
||||
local text = meta:get_string("text", "")
|
||||
if fields and (text == "" and fields.text) then
|
||||
meta:set_string("text", fields.text)
|
||||
text = fields.text
|
||||
|
@ -1843,19 +1900,8 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
|||
return false
|
||||
end
|
||||
|
||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
||||
local text_entity
|
||||
for _, v in ipairs(objects) do
|
||||
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
|
||||
text_entity = mcl_signs:get_text_entity(pos,force_remove)
|
||||
|
||||
if not text_entity then
|
||||
if DEBUG then
|
||||
|
@ -1899,11 +1945,29 @@ function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color)
|
|||
text_entity:set_yaw(sign_info.yaw)
|
||||
if DEBUG then
|
||||
minetest.log("verbose", "[mcl_signs] Update_Sign: After texture recreation.")
|
||||
minetest.log("action","[mcl_signs] Update_Sign: " .. npos_name .. "\nPlaced position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info))
|
||||
minetest.log("action", "[mcl_signs] Update_Sign: " .. npos_name .. "\nPlaced position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info))
|
||||
end
|
||||
|
||||
-- save sign metadata.
|
||||
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
|
||||
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))
|
||||
|
@ -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")) .. "]"
|
||||
)
|
||||
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