Compare commits
12 Commits
dev
...
version_4.
Author | SHA1 | Date | |
---|---|---|---|
bd9707abfe | |||
0f7badedd9 | |||
e2938bf17e | |||
2907b3dd0c | |||
73bf457a8c | |||
ad28a5b7f6 | |||
e403d916d2 | |||
03579c3912 | |||
f963f894ca | |||
d252588de1 | |||
7f84a95d1e | |||
de70260127 |
@ -1,2 +1,3 @@
|
|||||||
default
|
default
|
||||||
|
signs_lib?
|
||||||
locks?
|
locks?
|
60
init.lua
60
init.lua
@ -1,4 +1,5 @@
|
|||||||
--more_signs by addi
|
--arrow_signs by addi
|
||||||
|
--thanks to Jat15 for the new place and rotate-system.
|
||||||
--Code and Textures are under the CC by-sa 3.0 licence
|
--Code and Textures are under the CC by-sa 3.0 licence
|
||||||
--see: http://creativecommons.org/licenses/by-sa/3.0/
|
--see: http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ arrow_signs={}
|
|||||||
|
|
||||||
arrow_signs.formspec = "field[text;Sign text:;${text}]";
|
arrow_signs.formspec = "field[text;Sign text:;${text}]";
|
||||||
|
|
||||||
arrow_signs_on_place = function(itemstack, placer, pointed_thing)
|
arrow_signs.on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
local posabove = pointed_thing.above
|
local posabove = pointed_thing.above
|
||||||
local posunder = pointed_thing.under
|
local posunder = pointed_thing.under
|
||||||
@ -103,33 +104,35 @@ arrow_signs_on_place = function(itemstack, placer, pointed_thing)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function arrow_signs:savetext(pos, formname, fields, sender)
|
arrow_signs.savetext = function(pos, formname, fields, sender)
|
||||||
|
if fields.text then
|
||||||
if not minetest.get_player_privs(sender:get_player_name())["interact"] then
|
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")
|
minetest.chat_send_player(sender:get_player_name(), "error: you don't have permission to edit the sign. you need the interact priv")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if minetest.is_protected(pos, sender:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos, sender:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
fields.text = fields.text or ""
|
fields.text = fields.text or ""
|
||||||
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
|
||||||
"\" to sign at "..minetest.pos_to_string(pos))
|
"\" to sign at "..minetest.pos_to_string(pos));
|
||||||
meta:set_string("text", fields.text)
|
meta:set_string("text", fields.text)
|
||||||
text = arrow_signs:create_lines(fields.text)
|
local text,lines = arrow_signs.create_lines(fields.text)
|
||||||
meta:set_string("infotext", '"'..text..'"')
|
meta:set_string("infotext", '"'..text..'"')
|
||||||
i=0
|
if lines > 4 then
|
||||||
for wort in text:gfind("\n") do
|
minetest.chat_send_player(sender:get_player_name(),"Information: \nYou've written more than 5 lines. \nIt may be that not all lines are displayed. \nPlease remove the last entry")
|
||||||
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
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function arrow_signs:create_lines(text)
|
--this function creates the linebreaks
|
||||||
text = text:gsub("/", "\"\n\"")
|
arrow_signs.create_lines = function(text)
|
||||||
text = text:gsub("|", "\"\n\"")
|
local text, n = text:gsub("[ ]*(%|)[ ]*", '"\n"')--search for |
|
||||||
return text
|
local text, m = text:gsub("[ ]*(%/)[ ]*", '"\n"')--search for /
|
||||||
|
return text, n+m
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.override_item("default:sign_wall", {
|
minetest.override_item("default:sign_wall", {
|
||||||
@ -149,15 +152,12 @@ minetest.register_node("arrow_signs:wall", {
|
|||||||
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
|
{ 0.30, -0.5, 0.5, -0.30, 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"},
|
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",
|
inventory_image = "arrow_sign.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -166,16 +166,14 @@ minetest.register_node("arrow_signs:wall", {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
groups = {choppy=2,dig_immediate=2,sign=1},
|
groups = {choppy=2,dig_immediate=2,sign=1},
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
on_place = arrow_signs_on_place,
|
on_place = arrow_signs.on_place,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
--local n = minetest.get_node(pos)
|
--local n = minetest.get_node(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", arrow_signs.formspec)
|
meta:set_string("formspec", arrow_signs.formspec)
|
||||||
meta:set_string("infotext", "\"\"")
|
meta:set_string("infotext", [[""]])
|
||||||
end,
|
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
|
||||||
arrow_signs:savetext(pos, formname, fields, sender)
|
|
||||||
end,
|
end,
|
||||||
|
on_receive_fields = arrow_signs.savetext,
|
||||||
})
|
})
|
||||||
|
|
||||||
--Recipes
|
--Recipes
|
||||||
|
@ -11,15 +11,12 @@ minetest.register_node("arrow_signs:shared_locked", {
|
|||||||
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
{ 0.0625, -0.375, 0.5, -0.0625, -0.437, 0.47}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{ 0.25, -0.25, 0.5, -0.25, 0.5, 0.47},
|
{ 0.30, -0.5, 0.5, -0.30, 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"},
|
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",
|
inventory_image = "arrow_sign.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -29,14 +26,16 @@ minetest.register_node("arrow_signs:shared_locked", {
|
|||||||
groups = {choppy=2,dig_immediate=2,sign_locked=1},
|
groups = {choppy=2,dig_immediate=2,sign_locked=1},
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
|
|
||||||
on_place = arrow_signs_on_place,
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
arrow_signs.on_place(itemstack, placer, pointed_thing);
|
||||||
|
locks:lock_set_owner( pointed_thing.above, placer, "Shared locked sign" );
|
||||||
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
-- prepare the lock of the sign
|
-- prepare the lock of the sign
|
||||||
locks:lock_init( pos,
|
locks:lock_init( pos,
|
||||||
"size[8,4]"..
|
"size[8,4]"..
|
||||||
"field[0.3,0.6;6,0.7;text;Text:;]"..
|
"field[0.3,0.6;6,0.7;text;Text:;${text}]"..
|
||||||
"field[0.3,3.6;6,0.7;locks_sent_lock_command;Locked sign. Type /help for help:;]"..
|
"field[0.3,3.6;6,0.7;locks_sent_lock_command;Locked sign. Type /help for help:;]"..
|
||||||
"button_exit[6.3,3.2;1.7,0.7;locks_sent_input;Proceed]" );
|
"button_exit[6.3,3.2;1.7,0.7;locks_sent_input;Proceed]" );
|
||||||
end,
|
end,
|
||||||
@ -57,18 +56,21 @@ minetest.register_node("arrow_signs:shared_locked", {
|
|||||||
and ( not(fields.locks_sent_lock_command)
|
and ( not(fields.locks_sent_lock_command)
|
||||||
or fields.locks_sent_lock_command=="")
|
or fields.locks_sent_lock_command=="")
|
||||||
and locks:lock_allow_use( pos, sender )) then
|
and locks:lock_allow_use( pos, sender )) then
|
||||||
|
--then save the text to the sign meta
|
||||||
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
fields.text = fields.text or "";
|
fields.text = fields.text or "";
|
||||||
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
|
||||||
"\" to sign at "..minetest.pos_to_string(pos));
|
"\" to sign at "..minetest.pos_to_string(pos));
|
||||||
meta:set_string("text", fields.text.." ["..sender:get_player_name().."]");
|
meta:set_string("text", fields.text);
|
||||||
meta:set_string("infotext", '"'..fields.text..'"'.." ["..sender:get_player_name().."]");
|
local text = arrow_signs.create_lines(fields.text)
|
||||||
|
meta:set_string("infotext", '"'..text..'"'.." ["..sender:get_player_name().."]");
|
||||||
|
|
||||||
-- a command for the lock?
|
-- a command for the lock?
|
||||||
else
|
else
|
||||||
arrow_signs:savetext( pos, formname, fields, sender );
|
--do nothing, because user does not have the right to change the sign
|
||||||
|
--a warning message is also printed by the locks mod
|
||||||
|
--arrow_signs.savetext( pos, formname, fields, sender );
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
Reference in New Issue
Block a user