ADD: added a List parameter to tnp3clone.lua script.

This commit is contained in:
iceman1001 2015-05-11 19:38:53 +02:00
commit f288cb607f
2 changed files with 17 additions and 5 deletions

View file

@ -363,7 +363,15 @@ local function find( main, sub)
end end
return nil return nil
end end
local function list()
print ("Type\tSub\tElement\tGame Name")
print (string.rep('=', 54))
for k, v in pairs(_names) do
print(("%s\t%s\t%s\t%-9s\t%s"):format(v[2],v[3],v[4], v[5], v[6] ))
end
end
return { return {
Find = find, Find = find,
List = list,
} }

View file

@ -13,6 +13,7 @@ local band = bit32.band
example =[[ example =[[
script run tnp3clone script run tnp3clone
script run tnp3clone -h script run tnp3clone -h
script run tnp3clone -l
script run tnp3clone -t aa00 -s 0030 script run tnp3clone -t aa00 -s 0030
]] ]]
@ -23,7 +24,8 @@ This script will try making a barebone clone of a tnp3 tag on to a magic generat
Arguments: Arguments:
-h : this help -h : this help
-t <data> : toytype id, 4hex symbols. -l : list all known toy tokens
-t <data> : toytype id, 4hex symbols
-s <data> : subtype id, 4hex symbols -s <data> : subtype id, 4hex symbols
For fun, try the following subtype id: For fun, try the following subtype id:
@ -98,10 +100,11 @@ local function main(args)
local DEBUG = true local DEBUG = true
-- Arguments for the script -- Arguments for the script
for o, a in getopt.getopt(args, 'ht:s:') do for o, a in getopt.getopt(args, 'ht:s:l') do
if o == "h" then return help() end if o == "h" then return help() end
if o == "t" then toytype = a end if o == "t" then toytype = a end
if o == "s" then subtype = a end if o == "s" then subtype = a end
if o == "l" then return toys.List() end
end end
if #toytype ~= 4 then return oops('Wrong size - toytype. (4hex symbols)') end if #toytype ~= 4 then return oops('Wrong size - toytype. (4hex symbols)') end
@ -140,7 +143,8 @@ local function main(args)
local cmd = (csetuid..'%s 0004 08 w'):format(result.uid) local cmd = (csetuid..'%s 0004 08 w'):format(result.uid)
core.console(cmd) core.console(cmd)
local b1 = toytype..'00000000000000000000'..subtype local b1 = toytype..string.rep('00',10)..subtype
local calc = utils.Crc16(b0..b1) local calc = utils.Crc16(b0..b1)
local calcEndian = bor(rsh(calc,8), lsh(band(calc, 0xff), 8)) local calcEndian = bor(rsh(calc,8), lsh(band(calc, 0xff), 8))