2013-07-14 17:26:30 +02:00
--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 = { }
2014-07-20 08:22:02 +02:00
arrow_signs.formspec = " field[text;Sign text:;${text}] " ;
2013-07-14 17:26:30 +02:00
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
2014-01-05 17:08:59 +01:00
local meta = minetest.get_meta ( pos )
2013-07-14 17:26:30 +02:00
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 ( ) , " \t Information: \n You'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
2014-07-20 08:22:02 +02:00
minetest.override_item ( " default:sign_wall " , {
groups = { choppy = 2 , dig_immediate = 2 , attached_node = 1 , sign = 1 } ,
} )
2013-07-14 17:26:30 +02:00
--Sign right
minetest.register_node ( " arrow_signs:wall_right " , {
description = " Sign right " ,
drawtype = " signlike " ,
tiles = { " arrow_sign_right.png " } ,
inventory_image = " arrow_sign_right.png " ,
paramtype = " light " ,
paramtype2 = " wallmounted " ,
sunlight_propagates = true ,
walkable = false ,
selection_box = {
type = " wallmounted " ,
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
} ,
groups = { choppy = 2 , dig_immediate = 2 , attached_node = 1 , sign = 1 } ,
legacy_wallmounted = true ,
sounds = default.node_sound_defaults ( ) ,
on_construct = function ( pos )
2014-01-05 17:08:59 +01:00
--local n = minetest.get_node(pos)
local meta = minetest.get_meta ( pos )
2014-07-20 08:22:02 +02:00
meta : set_string ( " formspec " , arrow_signs.formspec )
2013-07-14 17:26:30 +02:00
meta : set_string ( " infotext " , " \" \" " )
end ,
on_receive_fields = function ( pos , formname , fields , sender )
arrow_signs : savetext ( pos , formname , fields , sender )
end ,
} )
-- sign left
minetest.register_node ( " arrow_signs:wall_left " , {
description = " Sign left " ,
drawtype = " signlike " ,
tiles = { " arrow_sign_left.png " } ,
inventory_image = " arrow_sign_left.png " ,
paramtype = " light " ,
paramtype2 = " wallmounted " ,
sunlight_propagates = true ,
walkable = false ,
selection_box = {
type = " wallmounted " ,
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
} ,
groups = { choppy = 2 , dig_immediate = 2 , attached_node = 1 , sign = 1 } ,
legacy_wallmounted = true ,
sounds = default.node_sound_defaults ( ) ,
on_construct = function ( pos )
2014-01-05 17:08:59 +01:00
--local n = minetest.get_node(pos)
local meta = minetest.get_meta ( pos )
2014-07-20 08:22:02 +02:00
meta : set_string ( " formspec " , arrow_signs.formspec )
2013-07-14 17:26:30 +02:00
meta : set_string ( " infotext " , " \" \" " )
end ,
on_receive_fields = function ( pos , formname , fields , sender )
arrow_signs : savetext ( pos , formname , fields , sender )
end ,
} )
--Sign up
minetest.register_node ( " arrow_signs:wall_up " , {
description = " Sign up " ,
drawtype = " signlike " ,
tiles = { " arrow_sign_up.png " } ,
inventory_image = " arrow_sign_up.png " ,
paramtype = " light " ,
paramtype2 = " wallmounted " ,
sunlight_propagates = true ,
walkable = false ,
selection_box = {
type = " wallmounted " ,
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
} ,
groups = { choppy = 2 , dig_immediate = 2 , attached_node = 1 , sign = 1 } ,
legacy_wallmounted = true ,
sounds = default.node_sound_defaults ( ) ,
on_construct = function ( pos )
2014-01-05 17:08:59 +01:00
--local n = minetest.get_node(pos)
local meta = minetest.get_meta ( pos )
2014-07-20 08:22:02 +02:00
meta : set_string ( " formspec " , arrow_signs.formspec )
2013-07-14 17:26:30 +02:00
meta : set_string ( " infotext " , " \" \" " )
end ,
on_receive_fields = function ( pos , formname , fields , sender )
arrow_signs : savetext ( pos , formname , fields , sender )
end ,
} )
--Sign down
minetest.register_node ( " arrow_signs:wall_down " , {
description = " Sign down " ,
drawtype = " signlike " ,
tiles = { " arrow_sign_down.png " } ,
inventory_image = " arrow_sign_down.png " ,
paramtype = " light " ,
paramtype2 = " wallmounted " ,
sunlight_propagates = true ,
walkable = false ,
selection_box = {
type = " wallmounted " ,
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
} ,
groups = { choppy = 2 , dig_immediate = 2 , attached_node = 1 , sign = 1 } ,
legacy_wallmounted = true ,
sounds = default.node_sound_defaults ( ) ,
on_construct = function ( pos )
2014-01-05 17:08:59 +01:00
--local n = minetest.get_node(pos)
local meta = minetest.get_meta ( pos )
2014-07-20 08:22:02 +02:00
meta : set_string ( " formspec " , arrow_signs.formspec )
2013-07-14 17:26:30 +02:00
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 ( {
output = ' arrow_signs:wall_right 1 ' ,
recipe = {
{ ' ' , ' ' , ' ' } ,
{ ' ' , ' group:sign ' , ' default:stick ' } ,
{ ' ' , ' ' , ' ' } ,
}
} )
minetest.register_craft ( {
output = ' arrow_signs:wall_left 1 ' ,
recipe = {
{ ' ' , ' ' , ' ' } ,
{ ' default:stick ' , ' group:sign ' , ' ' } ,
{ ' ' , ' ' , ' ' } ,
}
} )
minetest.register_craft ( {
output = ' arrow_signs:wall_up 1 ' ,
recipe = {
{ ' ' , ' default:stick ' , ' ' } ,
{ ' ' , ' group:sign ' , ' ' } ,
{ ' ' , ' ' , ' ' } ,
}
} )
minetest.register_craft ( {
output = ' arrow_signs:wall_down 1 ' ,
recipe = {
{ ' ' , ' ' , ' ' } ,
{ ' ' , ' group:sign ' , ' ' } ,
{ ' ' , ' default:stick ' , ' ' } ,
}
} )
minetest.register_craft ( {
output = ' default:sign_wall ' ,
recipe = {
{ ' group:sign ' } ,
}
} )
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 " )
2014-01-03 23:48:04 +01:00
minetest.register_alias ( " more_signs:wall_down " , " arrow_signs:wall_down " )
2013-07-14 17:26:30 +02:00
minetest.register_alias ( " sign_down " , " arrow_signs:wall_down " )
if locks then
local MODPATH = minetest.get_modpath ( " arrow_signs " ) ;
dofile ( MODPATH .. " /shared_locked.lua " )
end