full code
--[[
example format (furnace):
m@minecraft;s@stone;n@none
m:s&m:s&m:s
m:s&n:n&m:s
m:s&m:s&m:s
]]--
local function parse( str )
local tLines = {}
for line in str:gmatch( "[^\r\n]+" ) do
tLines[ #tLines + 1 ] = line
end
print( 'parsed lines' )
print( #tLines )
print( 'starting tShortcuts' )
local tShortcuts = {}
if tLines[ 1 ]:find( "@" ) then
print( "found shortcuts" )
--encoding is present
for s, o in tLines[ 1 ]:gmatch( "([^@]+)@(^;+);?" ) do
tShortcuts[ s ] = o
end
table.remove( tLines, 1 )
else
print( 'no shortcuts' )
end
print( #tLines )
print( #tShortcuts )
local tInv = {}
local row = 0
print( 'compiling tInv' )
for _, str in ipairs( tLines ) do
local l = 1
print( str )
for mod, item in str:gmatch( "([^:]+):(/>[^:\r\n]+)&?" ) do
print('')
tInv[ (row * 4) + l ] = ( tShortcuts[ mod ] or mod ) .. ":" .. ( tShortcuts[ item ] or item )
l = l + 1
end
row = row + 1
end
return tInv
end
example format
m@minecraft;s@stone;n@none
m:s&m:s&m:s
m:s&n&m:s
m:s&m:s&m:s
expected result vs result
{
[1] = "minecraft:stone",
[2] = "minecraft:stone",
[3] = "minecraft:stone",
[5] = "minecraft:stone",
[6] = "null:null",
[7] = "minecraft:stone",
[9] = "minecraft:stone",
[10] = "minecraft:stone",
[11] = "minecraft:stone",
}
vs
{
[1] = "m:s&m",
[2] = "s&m:s",
[5] = "m:s&n&m",
[10] = "s&m:s",
[9] = "m:s&m",
}
I will continue to resolve this myself, however help is appreciated.
PS: I'm a bit annoyed by this, but the forum editor is inserting html end tags ('/>') in my code at random. Please ignore them, this code does not give me errors; it just doesn't work.