update signs_lib and basic_signs

This commit is contained in:
Vanessa Dannenberg 2019-09-15 03:20:50 -04:00
parent 5556c8b83e
commit 9ba0eebc72
8 changed files with 122 additions and 41 deletions

View File

@ -9,44 +9,70 @@ dofile(basic_signs.path .. "/crafting.lua")
local S, NS = dofile(basic_signs.path .. "/intllib.lua") local S, NS = dofile(basic_signs.path .. "/intllib.lua")
basic_signs.gettext = S basic_signs.gettext = S
function basic_signs.determine_sign_type(pos, placer, itemstack, pointed_thing) function basic_signs.check_for_floor(pointed_thing)
if pointed_thing.above.x == pointed_thing.under.x
and pointed_thing.above.z == pointed_thing.under.z
and pointed_thing.above.y > pointed_thing.under.y then
return true
end
end
function basic_signs.determine_sign_type(pos, placer, itemstack, pointed_thing, widefont)
local playername = placer:get_player_name() local playername = placer:get_player_name()
local pt_name = minetest.get_node(pointed_thing.under).name local pt_name = minetest.get_node(pointed_thing.under).name
local node = minetest.get_node(pos) -- since we're in after-place, this will be the wall sign itself local node = minetest.get_node(pos) -- since we're in after-place, this will be the wall sign itself
local widefont = widefont or ""
if minetest.is_protected(pointed_thing.under, playername) then if minetest.is_protected(pointed_thing.under, playername) then
minetest.record_protection_violation(pointed_thing.under, playername) minetest.record_protection_violation(pointed_thing.under, playername)
return itemstack return itemstack
end end
local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
if minetest.registered_nodes[pt_name] and if minetest.registered_nodes[pt_name] and
minetest.registered_nodes[pt_name].on_rightclick and minetest.registered_nodes[pt_name].on_rightclick and
not placer:get_player_control().sneak then not placer:get_player_control().sneak then
return minetest.registered_nodes[pt_name].on_rightclick(pos, node, placer, itemstack, pointed_thing) return minetest.registered_nodes[pt_name].on_rightclick(pos, node, placer, itemstack, pointed_thing)
elseif signs_lib.check_for_pole(pos, pointed_thing) then elseif signs_lib.check_for_pole(pos, pointed_thing) then
minetest.swap_node(pos, {name = "default:sign_wall_wood_onpole", param2 = node.param2}) minetest.swap_node(pos, {name = "default:sign_wall_wood"..widefont.."_onpole", param2 = node.param2})
else elseif signs_lib.check_for_ceiling(pointed_thing) then
local lookdir = placer:get_look_dir() minetest.swap_node(pos, {name = "default:sign_wall_wood"..widefont.."_hanging", param2 = newparam2})
print(dump(lookdir)) elseif basic_signs.check_for_floor(pointed_thing) then
local newparam2 = minetest.dir_to_facedir(lookdir) minetest.swap_node(pos, {name = "basic_signs:yard_sign"..widefont, param2 = newparam2})
if node.param2 == 0 then
minetest.swap_node(pos, {name = "basic_signs:hanging_sign", param2 = newparam2})
elseif node.param2 == 1 then
minetest.swap_node(pos, {name = "basic_signs:yard_sign", param2 = newparam2})
end
signs_lib.update_sign(pos)
end end
signs_lib.update_sign(pos)
if not creative.is_enabled_for(playername) then if not creative.is_enabled_for(playername) then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
end end
local def
minetest.override_item("default:sign_wall_wood", { minetest.override_item("default:sign_wall_wood", {
after_place_node = basic_signs.determine_sign_type after_place_node = basic_signs.determine_sign_type
}) })
def = table.copy(minetest.registered_items["default:sign_wall_wood"])
def.description = "Wooden wall sign (wide font)"
def.inventory_image = def.inventory_image.."^signs_lib_wide_font_overlay_inv.png"
def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
def.horiz_scaling = signs_lib.standard_hscale / 2
def.after_place_node = function(pos, placer, itemstack, pointed_thing)
basic_signs.determine_sign_type(pos, placer, itemstack, pointed_thing, "_widefont")
end
signs_lib.register_sign("default:sign_wall_wood_widefont", def)
def = table.copy(minetest.registered_items["default:sign_wall_steel"])
def.description = "Steel wall sign (wide font)"
def.inventory_image = def.inventory_image.."^signs_lib_wide_font_overlay_inv.png"
def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
def.horiz_scaling = signs_lib.standard_hscale / 2
signs_lib.register_sign("default:sign_wall_steel_widefont", def)
signs_lib.register_sign("basic_signs:sign_wall_locked", { signs_lib.register_sign("basic_signs:sign_wall_locked", {
description = S("Locked Sign"), description = S("Locked Sign"),
tiles = { tiles = {
@ -56,10 +82,18 @@ signs_lib.register_sign("basic_signs:sign_wall_locked", {
inventory_image = "basic_signs_sign_wall_locked_inv.png", inventory_image = "basic_signs_sign_wall_locked_inv.png",
locked = true, locked = true,
entity_info = "standard", entity_info = "standard",
allow_hanging = true
}) })
minetest.register_alias("locked_sign:sign_wall_locked", "basic_signs:sign_wall_locked") minetest.register_alias("locked_sign:sign_wall_locked", "basic_signs:sign_wall_locked")
def = table.copy(minetest.registered_items["basic_signs:sign_wall_locked"])
def.description = S("Locked Sign (wide font)")
def.inventory_image = def.inventory_image.."^signs_lib_wide_font_overlay_inv.png"
def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
def.horiz_scaling = signs_lib.standard_hscale / 2
signs_lib.register_sign("basic_signs:sign_wall_locked_widefont", def)
-- array : color, translated color, default text color -- array : color, translated color, default text color
local sign_colors = { local sign_colors = {
@ -93,12 +127,23 @@ for i, color in ipairs(sign_colors) do
mesh = "signs_lib_standard_wall_sign_entity.obj", mesh = "signs_lib_standard_wall_sign_entity.obj",
yaw = signs_lib.standard_yaw yaw = signs_lib.standard_yaw
}, },
allow_hanging = true
}) })
def = table.copy(minetest.registered_items["basic_signs:sign_wall_steel_"..color[1]])
def.description = S("Sign (@1, steel, wide font)", color[2])
def.horiz_scaling = signs_lib.standard_hscale / 2
def.inventory_image = def.inventory_image.."^signs_lib_wide_font_overlay_inv.png"
def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
signs_lib.register_sign("basic_signs:sign_wall_steel_widefont_"..color[1], def)
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_wall_"..color[1]) table.insert(signs_lib.lbm_restore_nodes, "signs:sign_wall_"..color[1])
minetest.register_alias("signs:sign_wall_"..color[1], "basic_signs:sign_wall_steel_"..color[1]) minetest.register_alias("signs:sign_wall_"..color[1], "basic_signs:sign_wall_steel_"..color[1])
end end
local wgroups = table.copy(signs_lib.standard_wood_groups)
wgroups.not_in_creative_inventory = 1
signs_lib.register_sign("basic_signs:yard_sign", { signs_lib.register_sign("basic_signs:yard_sign", {
description = "Wooden yard sign", description = "Wooden yard sign",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -114,31 +159,19 @@ signs_lib.register_sign("basic_signs:yard_sign", {
mesh = "basic_signs_yard_sign_entity.obj", mesh = "basic_signs_yard_sign_entity.obj",
yaw = signs_lib.standard_yaw yaw = signs_lib.standard_yaw
}, },
groups = wgroups,
drop = "default:sign_wall_wood", drop = "default:sign_wall_wood",
allow_onpole = false allow_onpole = false
}) })
signs_lib.register_sign("basic_signs:hanging_sign", { def = table.copy(minetest.registered_items["basic_signs:yard_sign"])
description = "Wooden sign, hanging", def.description = "Wooden yard sign (wide font)"
paramtype2 = "facedir", def.inventory_image = def.inventory_image.."^signs_lib_wide_font_overlay_inv.png"
selection_box = signs_lib.make_selection_boxes(35, 32, false, 0, 3, -18.5, true), def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
mesh = "basic_signs_hanging_sign.obj", def.wield_image = def.wield_image.."^signs_lib_wide_font_overlay_inv.png"
tiles = { def.horiz_scaling = signs_lib.standard_hscale / 2
"signs_lib_sign_wall_wooden.png", def.groups = wgroups
"signs_lib_sign_wall_wooden_edges.png", minetest.register_node("basic_signs:yard_sign_widefont", def)
"basic_signs_ceiling_hangers.png"
},
inventory_image = "default_sign_wood.png",
entity_info = {
mesh = "basic_signs_hanging_sign_entity.obj",
yaw = signs_lib.standard_yaw
},
drop = "default:sign_wall_wood",
allow_onpole = false
})
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_yard") table.insert(signs_lib.lbm_restore_nodes, "signs:sign_yard")
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_hanging")
minetest.register_alias("signs:sign_yard", "basic_signs:yard_sign") minetest.register_alias("signs:sign_yard", "basic_signs:yard_sign")
minetest.register_alias("signs:sign_hanging", "basic_signs:hanging_sign")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

View File

@ -611,6 +611,14 @@ function signs_lib.check_for_pole(pos, pointed_thing)
end end
end end
function signs_lib.check_for_ceiling(pointed_thing)
if pointed_thing.above.x == pointed_thing.under.x
and pointed_thing.above.z == pointed_thing.under.z
and pointed_thing.above.y < pointed_thing.under.y then
return true
end
end
function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked) function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked)
local playername = placer:get_player_name() local playername = placer:get_player_name()
local def = minetest.registered_items[itemstack:get_name()] local def = minetest.registered_items[itemstack:get_name()]
@ -622,6 +630,10 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
if (def.allow_onpole ~= false) and signs_lib.check_for_pole(pos, pointed_thing) then if (def.allow_onpole ~= false) and signs_lib.check_for_pole(pos, pointed_thing) then
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = itemstack:get_name().."_onpole", param2 = node.param2}) minetest.swap_node(pos, {name = itemstack:get_name().."_onpole", param2 = node.param2})
elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) then
local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = itemstack:get_name().."_hanging", param2 = newparam2})
end end
if locked then if locked then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -711,13 +723,13 @@ function signs_lib.register_sign(name, rdef)
end end
def.paramtype = rdef.paramtype or "light" def.paramtype = rdef.paramtype or "light"
def.paramtype2 = rdef.paramtype2 or "wallmounted"
def.drawtype = rdef.drawtype or "mesh" def.drawtype = rdef.drawtype or "mesh"
def.mesh = rdef.mesh or "signs_lib_standard_wall_sign.obj" def.mesh = rdef.mesh or "signs_lib_standard_wall_sign.obj"
def.wield_image = rdef.wield_image or def.inventory_image def.wield_image = rdef.wield_image or def.inventory_image
def.drop = rdef.drop or name def.drop = rdef.drop or name
def.sounds = rdef.sounds or signs_lib.standard_wood_sign_sounds def.sounds = rdef.sounds or signs_lib.standard_wood_sign_sounds
def.on_rotate = rdef.on_rotate or signs_lib.wallmounted_rotate def.on_rotate = rdef.on_rotate or signs_lib.wallmounted_rotate
def.paramtype2 = rdef.paramtype2 or "wallmounted"
if rdef.on_rotate then if rdef.on_rotate then
def.on_rotate = rdef.on_rotate def.on_rotate = rdef.on_rotate
@ -754,6 +766,9 @@ function signs_lib.register_sign(name, rdef)
offset = 0.35 offset = 0.35
end end
opdef.selection_box = rdef.onpole_selection_box or opdef.selection_box
opdef.node_box = rdef.onpole_node_box or opdef.selection_box
if opdef.paramtype2 == "wallmounted" then if opdef.paramtype2 == "wallmounted" then
opdef.node_box.wall_side[1] = def.node_box.wall_side[1] - offset opdef.node_box.wall_side[1] = def.node_box.wall_side[1] - offset
opdef.node_box.wall_side[4] = def.node_box.wall_side[4] - offset opdef.node_box.wall_side[4] = def.node_box.wall_side[4] - offset
@ -780,6 +795,31 @@ function signs_lib.register_sign(name, rdef)
minetest.register_node(":"..name.."_onpole", opdef) minetest.register_node(":"..name.."_onpole", opdef)
table.insert(signs_lib.lbm_restore_nodes, name.."_onpole") table.insert(signs_lib.lbm_restore_nodes, name.."_onpole")
end end
if rdef.allow_hanging then
local hdef = table.copy(def)
hdef.paramtype2 = "facedir"
local hcbox = signs_lib.make_selection_boxes(35, 32, false, 0, 3, -18.5, true)
hdef.selection_box = rdef.hanging_selection_box or hcbox
hdef.node_box = rdef.hanging_node_box or rdef.hanging_selection_box or hcbox
hdef.groups.not_in_creative_inventory = 1
hdef.tiles[3] = "signs_lib_hangers.png"
hdef.mesh = string.gsub(string.gsub(hdef.mesh, "_facedir.obj", ".obj"), ".obj$", "_hanging.obj")
hdef.on_rotate = nil
if hdef.entity_info then
hdef.entity_info.mesh = string.gsub(string.gsub(hdef.entity_info.mesh, "_facedir.obj", ".obj"), ".obj$", "_hanging.obj")
hdef.entity_info.yaw = signs_lib.standard_yaw
end
minetest.register_node(":"..name.."_hanging", hdef)
table.insert(signs_lib.lbm_restore_nodes, name.."_hanging")
end
end end
-- restore signs' text after /clearobjects and the like, the next time -- restore signs' text after /clearobjects and the like, the next time

View File

@ -17,9 +17,9 @@ v -0.437500 -0.312500 0.031250
v -0.437500 -0.312500 -0.031250 v -0.437500 -0.312500 -0.031250
v -0.437500 0.312500 0.031250 v -0.437500 0.312500 0.031250
v -0.437500 0.312500 -0.031250 v -0.437500 0.312500 -0.031250
v 0.500000 0.312500 0.000000 v 0.500000 0.312500 -0.000000
v 0.500000 0.500000 0.000000 v 0.500000 0.500000 0.000000
v -0.500000 0.312500 0.000000 v -0.500000 0.312500 -0.000000
v -0.500000 0.500000 0.000000 v -0.500000 0.500000 0.000000
vt 0.468750 0.812500 vt 0.468750 0.812500
vt 0.031250 0.812500 vt 0.031250 0.812500
@ -47,8 +47,8 @@ vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000 vn 0.0000 -0.0000 1.0000
vn 0.0000 -1.0000 0.0000 vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000 vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000 vn 1.0000 -0.0000 0.0000
vn -1.0000 0.0000 0.0000 vn -1.0000 -0.0000 0.0000
g Cube_Cube_front-back g Cube_Cube_front-back
s off s off
f 8/1/1 4/2/1 2/3/1 6/4/1 f 8/1/1 4/2/1 2/3/1 6/4/1

View File

@ -7,7 +7,8 @@ signs_lib.register_sign("default:sign_wall_wood", {
"signs_lib_sign_wall_wooden.png", "signs_lib_sign_wall_wooden.png",
"signs_lib_sign_wall_wooden_edges.png", "signs_lib_sign_wall_wooden_edges.png",
}, },
entity_info = "standard" entity_info = "standard",
allow_hanging = true,
}) })
signs_lib.register_sign("default:sign_wall_steel", { signs_lib.register_sign("default:sign_wall_steel", {
@ -20,9 +21,16 @@ signs_lib.register_sign("default:sign_wall_steel", {
groups = signs_lib.standard_steel_groups, groups = signs_lib.standard_steel_groups,
sounds = signs_lib.standard_steel_sign_sounds, sounds = signs_lib.standard_steel_sign_sounds,
locked = true, locked = true,
entity_info = "standard" entity_info = "standard",
allow_hanging = true,
}) })
minetest.register_alias("signs:sign_hanging", "default:sign_wall_wood_hanging")
minetest.register_alias("basic_signs:hanging_sign", "default:sign_wall_wood_hanging")
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_hanging")
table.insert(signs_lib.lbm_restore_nodes, "basic_signs:hanging_sign")
-- insert the old wood sign-on-fencepost into signs_lib's conversion LBM -- insert the old wood sign-on-fencepost into signs_lib's conversion LBM
table.insert(signs_lib.old_fenceposts_with_signs, "signs:sign_post") table.insert(signs_lib.old_fenceposts_with_signs, "signs:sign_post")

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 B