From 2af7255f629d247437c7afc7d625ab568dd7bcf8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 7 May 2019 22:12:18 +0200 Subject: [PATCH] textual --- client/scripts/calc_ev1_it.lua | 18 ++++++++++-------- client/scripts/tnp3clone.lua | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/client/scripts/calc_ev1_it.lua b/client/scripts/calc_ev1_it.lua index b4e995e96..89e778023 100644 --- a/client/scripts/calc_ev1_it.lua +++ b/client/scripts/calc_ev1_it.lua @@ -31,22 +31,22 @@ local bxor = bit32.bxor -- A debug printout-function local function dbg(args) if not DEBUG then return end - - if type(args) == "table" then + if type(args) == 'table' then local i = 1 while args[i] do dbg(args[i]) i = i+1 end else - print("###", args) + print('###', args) end end --- -- This is only meant to be used when errors occur local function oops(err) - print("ERROR: ",err) - return nil,err + print('ERROR: ', err) + core.clearCommandBuffer() + return nil, err end --- -- Usage help @@ -57,10 +57,11 @@ local function help() print(desc) print("Example usage") print(example) + print(usage) end -- -- Exit message -function exitMsg(msg) +local function exitMsg(msg) print( string.rep('--',20) ) print( string.rep('--',20) ) print(msg) @@ -138,6 +139,7 @@ local function pwdgen(uid) local pwd3 = bxor( entry[4], uidbytes[7]) return string.format('%02X%02X%02X%02X', pwd0, pwd1, pwd2, pwd3) end + -- -- main local function main(args) @@ -151,8 +153,8 @@ local function main(args) -- Arguments for the script for o, a in getopt.getopt(args, 'hu:') do - if o == "h" then return help() end - if o == "u" then uid = a; useUID = true end + if o == 'h' then return help() end + if o == 'u' then uid = a; useUID = true end end if useUID then diff --git a/client/scripts/tnp3clone.lua b/client/scripts/tnp3clone.lua index 1e3545a1b..b168c9d1a 100644 --- a/client/scripts/tnp3clone.lua +++ b/client/scripts/tnp3clone.lua @@ -135,11 +135,11 @@ local function main(args) --13-14 -- find tag - result, err = lib14a.read(false, true) - if not result then return oops(err) end + local card, err = lib14a.read(false, true) + if not card then return oops(err) end -- load keys - local akeys = pre.GetAll(result.uid) + local akeys = pre.GetAll(card.uid) local keyA = akeys:sub(1, 12 ) local b0 = readblock(0, keyA) @@ -154,7 +154,7 @@ local function main(args) core.clearCommandBuffer() -- wipe card. - local cmd = (csetuid..'%s %s %s w'):format(result.uid, atqa, sak) + local cmd = (csetuid..'%s %s %s w'):format(card.uid, atqa, sak) core.console(cmd) core.clearCommandBuffer()