135668b35c
"Sign right" does not stick to the wall...
153 lines
4.7 KiB
Lua
153 lines
4.7 KiB
Lua
--more_signs by addi
|
|
--Code and Textures are under the CC by-sa 3.0 licence
|
|
--see: http://creativecommons.org/licenses/by-sa/3.0/
|
|
|
|
|
|
|
|
arrow_signs={}
|
|
|
|
function arrow_signs:savetext(pos, formname, fields, sender)
|
|
|
|
if not minetest.get_player_privs(sender:get_player_name())["interact"] then
|
|
minetest.chat_send_player(sender:get_player_name(), "error: you don't have permission to edit the sign. you need the interact priv")
|
|
return
|
|
end
|
|
local meta = minetest.get_meta(pos)
|
|
fields.text = fields.text or ""
|
|
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
|
"\" to sign at "..minetest.pos_to_string(pos))
|
|
meta:set_string("text", fields.text)
|
|
text = arrow_signs:create_lines(fields.text)
|
|
meta:set_string("infotext", '"'..text..'"')
|
|
i=0
|
|
for wort in text:gfind("\n") do
|
|
i=i+1
|
|
end
|
|
if i > 4 then
|
|
minetest.chat_send_player(sender:get_player_name(),"\tInformation: \nYou've written more than 5 lines. \n it may be that not all lines are displayed. \n Please remove the last entry")
|
|
end
|
|
return true
|
|
end
|
|
|
|
function arrow_signs:create_lines(text)
|
|
text = text:gsub("/", "\"\n\"")
|
|
text = text:gsub("|", "\"\n\"")
|
|
return text
|
|
end
|
|
|
|
|
|
local clone_registered = function(case,name)
|
|
local params = {}
|
|
local list
|
|
if case == "item" then list = minetest.registered_items end
|
|
if case == "node" then list = minetest.registered_nodes end
|
|
if case == "craftitem" then list = minetest.registered_craftitems end
|
|
if case == "tool" then list = minetest.registered_tools end
|
|
if case == "entity" then list = minetest.registered_entities end
|
|
if list then
|
|
for k,v in pairs(list[name]) do
|
|
params[k] = v
|
|
end
|
|
end
|
|
return params
|
|
end
|
|
|
|
-- usage
|
|
local node = clone_registered("node","default:sign_wall")
|
|
if node.legacy_wallmounted then
|
|
node.groups = {choppy=2,dig_immediate=2,attached_node=1,sign=1}
|
|
else
|
|
node.groups = {choppy=2,dig_immediate=2,sign=1}
|
|
end
|
|
minetest.register_node(":default:sign_wall", node)
|
|
|
|
--Sign arrow
|
|
minetest.register_node("arrow_signs:wall", {
|
|
description = "Arrow signs",
|
|
drawtype = "nodebox",
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
|
|
{ 0.1875, -0.3125, 0.5, -0.1875, -0.25, 0.47},
|
|
{ 0.125, -0.3125, 0.5, -0.125, -0.375, 0.47},
|
|
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
|
}
|
|
},
|
|
selection_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
|
|
{ 0.1875, -0.3125, 0.5, -0.1875, -0.25, 0.47},
|
|
{ 0.125, -0.3125, 0.5, -0.125, -0.375, 0.47},
|
|
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
|
}
|
|
},
|
|
tiles = {"arrow_sign_border_left.png","arrow_sign_border_right.png","arrow_sign_border_up.png","arrow_sign_border_down.png","arrow_sign.png","arrow_sign.png"},
|
|
inventory_image = "arrow_sign.png",
|
|
paramtype = "light",
|
|
paramtype2 = "facedir",
|
|
sunlight_propagates = true,
|
|
walkable = false,
|
|
groups = {choppy=2,dig_immediate=2,sign=1},
|
|
sounds = default.node_sound_defaults(),
|
|
on_place = minetest.rotate_node,
|
|
on_construct = function(pos)
|
|
--local n = minetest.get_node(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("formspec", "hack:sign_text_input")
|
|
meta:set_string("infotext", "\"\"")
|
|
end,
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
arrow_signs:savetext(pos, formname, fields, sender)
|
|
end,
|
|
})
|
|
|
|
--Recipes
|
|
minetest.register_craft({
|
|
type = 'shapeless',
|
|
output = 'arrow_signs:wall',
|
|
recipe = {'group:sign', 'default:stick'},
|
|
})
|
|
minetest.register_craft({
|
|
output = 'default:sign_wall',
|
|
recipe = {
|
|
{'group:sign'},
|
|
}
|
|
})
|
|
|
|
--Alias
|
|
minetest.register_alias("more_signs:wall_right", "arrow_signs:wall_right")
|
|
minetest.register_alias("sign_right", "arrow_signs:wall_right")
|
|
|
|
minetest.register_alias("more_signs:wall_left", "arrow_signs:wall_left")
|
|
minetest.register_alias("sign_left", "arrow_signs:wall_left")
|
|
|
|
minetest.register_alias("more_signs:wall_up", "arrow_signs:wall_up")
|
|
minetest.register_alias("sign_up", "arrow_signs:wall_up")
|
|
|
|
minetest.register_alias("more_signs:wall_down", "arrow_signs:wall_down")
|
|
minetest.register_alias("sign_down", "arrow_signs:wall_down")
|
|
|
|
--Redefinition
|
|
minetest.register_abm({
|
|
nodenames = {"arrow_signs:wall_right", "arrow_signs:wall_left", "arrow_signs:wall_up", "arrow_signs:wall_down"},
|
|
interval = 1,
|
|
chance = 1,
|
|
action = function(pos, node)
|
|
local convert_facedir={
|
|
["arrow_signs:wall_right"]={6,4,5,11,16,14},
|
|
["arrow_signs:wall_left"]={8,10,9,7,12,18},
|
|
["arrow_signs:wall_up"]={15,19,23,21,20,22},
|
|
["arrow_signs:wall_down"]={17,13,1,3,0,2}
|
|
}
|
|
minetest.swap_node(pos, {name="arrow_signs:wall",param2=convert_facedir[node.name][node.param2+1]})
|
|
end,
|
|
})
|
|
|
|
|
|
--Locked sign
|
|
if locks then
|
|
local MODPATH = minetest.get_modpath("arrow_signs");
|
|
dofile(MODPATH.."/shared_locked.lua")
|
|
end |