slprogtools: read-only flag for memory copier added.
Memory Copier dongle can now be write-protected. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
parent
959a0a42fa
commit
c41fbd41f4
@ -40,7 +40,7 @@ git clone https://github.com/realmicu/minetest-micupack.git micupack
|
|||||||
Devices for interacting with SaferLua Controller from TechPack mod:
|
Devices for interacting with SaferLua Controller from TechPack mod:
|
||||||
|
|
||||||
- Memory Copier - portable dongle to transfer code between SL Controllers in much simpler
|
- Memory Copier - portable dongle to transfer code between SL Controllers in much simpler
|
||||||
and faster way than copying it with text books
|
and faster way than copying it with text books; can be write-protected
|
||||||
- Memory Programmer - improved Memory Copier, with read/write protection to prevent
|
- Memory Programmer - improved Memory Copier, with read/write protection to prevent
|
||||||
accidental memory loss and code injection functionality (works like original Programmer
|
accidental memory loss and code injection functionality (works like original Programmer
|
||||||
but for SL Controllers); it allows to replace special marker in init() section
|
but for SL Controllers); it allows to replace special marker in init() section
|
||||||
|
@ -155,6 +155,7 @@ local function formspec_copier(tool, tubelib_id)
|
|||||||
local init_flag = tool_meta:get_int("init_flag") ~= 0
|
local init_flag = tool_meta:get_int("init_flag") ~= 0
|
||||||
local loop_flag = tool_meta:get_int("loop_flag") ~= 0
|
local loop_flag = tool_meta:get_int("loop_flag") ~= 0
|
||||||
local note_flag = tool_meta:get_int("note_flag") ~= 0
|
local note_flag = tool_meta:get_int("note_flag") ~= 0
|
||||||
|
local ro_flag = tool_meta:get_int("ro_flag") ~= 0
|
||||||
local init_len = string.len(tool_meta:get_string("init_code"))
|
local init_len = string.len(tool_meta:get_string("init_code"))
|
||||||
local loop_len = string.len(tool_meta:get_string("loop_code"))
|
local loop_len = string.len(tool_meta:get_string("loop_code"))
|
||||||
local note_len = string.len(tool_meta:get_string("note_text"))
|
local note_len = string.len(tool_meta:get_string("note_text"))
|
||||||
@ -168,12 +169,14 @@ local function formspec_copier(tool, tubelib_id)
|
|||||||
"checkbox[0.5,1.5;init_flag;include " .. msg_M .. "init()" .. msg_W ..
|
"checkbox[0.5,1.5;init_flag;include " .. msg_M .. "init()" .. msg_W ..
|
||||||
" code (size: " .. tostring(init_len) .. ");" ..
|
" code (size: " .. tostring(init_len) .. ");" ..
|
||||||
tostring(init_flag) .. "]" ..
|
tostring(init_flag) .. "]" ..
|
||||||
"checkbox[0.5,2.25;loop_flag;include " .. msg_M .. "loop()" .. msg_W ..
|
"checkbox[0.5,2;loop_flag;include " .. msg_M .. "loop()" .. msg_W ..
|
||||||
" code (size: " .. tostring(loop_len) .. ");" ..
|
" code (size: " .. tostring(loop_len) .. ");" ..
|
||||||
tostring(loop_flag) .. "]" ..
|
tostring(loop_flag) .. "]" ..
|
||||||
"checkbox[0.5,3;note_flag;include " .. msg_M .. "notes" .. msg_W ..
|
"checkbox[0.5,2.5;note_flag;include " .. msg_M .. "notes" .. msg_W ..
|
||||||
" text (size: " .. tostring(note_len) .. ");" ..
|
" text (size: " .. tostring(note_len) .. ");" ..
|
||||||
tostring(note_flag) .. "]" ..
|
tostring(note_flag) .. "]" ..
|
||||||
|
"checkbox[0.5,3;ro_flag;read only (archive mode);" ..
|
||||||
|
tostring(ro_flag) .. "]" ..
|
||||||
"button_exit[5,0.75;1.5,1;clear;Clear]" ..
|
"button_exit[5,0.75;1.5,1;clear;Clear]" ..
|
||||||
"button_exit[5,1.5;1.5,1;download;Download]" ..
|
"button_exit[5,1.5;1.5,1;download;Download]" ..
|
||||||
"button_exit[5,2.25;1.5,1;upload;Upload]" ..
|
"button_exit[5,2.25;1.5,1;upload;Upload]" ..
|
||||||
@ -312,6 +315,10 @@ local function init_metadata_copier(player, tool)
|
|||||||
local tool_meta = tool:get_meta()
|
local tool_meta = tool:get_meta()
|
||||||
local tool_upd = false
|
local tool_upd = false
|
||||||
local metatable = tool_meta:to_table()
|
local metatable = tool_meta:to_table()
|
||||||
|
if not metatable.fields["ro_flag"] then
|
||||||
|
tool_meta:set_int("ro_flag", 0)
|
||||||
|
tool_upd = true
|
||||||
|
end
|
||||||
if not metatable.fields["init_flag"] then
|
if not metatable.fields["init_flag"] then
|
||||||
tool_meta:set_int("init_flag", 1)
|
tool_meta:set_int("init_flag", 1)
|
||||||
tool_upd = true
|
tool_upd = true
|
||||||
@ -350,10 +357,6 @@ local function init_metadata_programmer(player, tool)
|
|||||||
tool_meta:set_int("wo_flag", 0)
|
tool_meta:set_int("wo_flag", 0)
|
||||||
tool_upd = true
|
tool_upd = true
|
||||||
end
|
end
|
||||||
if not metatable.fields["ro_flag"] then
|
|
||||||
tool_meta:set_int("ro_flag", 0)
|
|
||||||
tool_upd = true
|
|
||||||
end
|
|
||||||
if not metatable.fields["prog_mark"] then
|
if not metatable.fields["prog_mark"] then
|
||||||
tool_meta:set_string("prog_mark", def_marker)
|
tool_meta:set_string("prog_mark", def_marker)
|
||||||
tool_upd = true
|
tool_upd = true
|
||||||
@ -461,20 +464,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
if fields.clear or fields.download or fields.upload then
|
if fields.clear or fields.download or fields.upload then
|
||||||
-- copier window or memory tab buttons
|
-- copier window or memory tab buttons
|
||||||
-- (this must work also for copier which has no RW flags)
|
-- (this must work also for copier which has no WO flag)
|
||||||
local ro_flag = tool_meta:get_int("ro_flag") == 1
|
local ro_flag = tool_meta:get_int("ro_flag") == 1
|
||||||
local wo_flag = tool_meta:get_int("wo_flag") == 1
|
local wo_flag = tool_meta:get_int("wo_flag") == 1
|
||||||
if (fields.clear or fields.download) and ro_flag then
|
if (fields.clear or fields.download) and ro_flag then
|
||||||
play_beep_err(player_name)
|
play_beep_err(player_name)
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
msg_Y .. "[" .. label .. "] " .. msg_R ..
|
msg_Y .. "[" .. label .. "] " .. msg_R ..
|
||||||
"Device memory is write-protected! (see security tab)")
|
"Device memory is write-protected!")
|
||||||
return true
|
return true
|
||||||
elseif fields.upload and wo_flag then
|
elseif fields.upload and wo_flag then
|
||||||
play_beep_err(player_name)
|
play_beep_err(player_name)
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
msg_Y .. "[" .. label .. "] " .. msg_R ..
|
msg_Y .. "[" .. label .. "] " .. msg_R ..
|
||||||
"Device memory is read-protected! (see security tab)")
|
"Device memory is read-protected!")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local init_flag = tool_meta:get_int("init_flag") ~= 0
|
local init_flag = tool_meta:get_int("init_flag") ~= 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user