update to version 4.1

fixed:
* text is saved if user exit formspec by pressign esc
* everybody was allowed to edit the locked arrow sign
* uninitialized global variable
* tidy up code
This commit is contained in:
adrido
2015-03-13 15:02:54 +01:00
parent 73bf457a8c
commit 2907b3dd0c
2 changed files with 29 additions and 23 deletions

View File

@ -26,14 +26,16 @@ minetest.register_node("arrow_signs:shared_locked", {
groups = {choppy=2,dig_immediate=2,sign_locked=1},
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)
local meta = minetest.get_meta(pos)
-- prepare the lock of the sign
locks:lock_init( pos,
"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:;]"..
"button_exit[6.3,3.2;1.7,0.7;locks_sent_input;Proceed]" );
end,
@ -48,24 +50,27 @@ minetest.register_node("arrow_signs:shared_locked", {
end,
on_receive_fields = function(pos, formname, fields, sender)
-- if the user already has the right to use this and did input text
if( fields.text
and ( not(fields.locks_sent_lock_command)
or fields.locks_sent_lock_command=="")
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))
local meta = minetest.get_meta(pos)
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));
meta:set_string("text", fields.text.." ["..sender:get_player_name().."]");
meta:set_string("infotext", '"'..fields.text..'"'.." ["..sender:get_player_name().."]");
meta:set_string("text", fields.text);
local text = arrow_signs.create_lines(fields.text)
meta:set_string("infotext", '"'..text..'"'.." ["..sender:get_player_name().."]");
-- a command for the lock?
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,