Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(s)
- if(s == nil or s == "") then
- return nil
- end
- local t = {}
- for w in string.gmatch(s, "%w+") do
- table.insert(t,w)
- end
- return t
- end
- function addList(name,mine,flag,drop,vein)
- if(fs.exists("listed")) then
- xlist = fs.open("listed","r")
- local x = split(xlist.readLine())
- while(x[1] ~= nil) do
- if(name == x[1]) then
- return false
- end
- s = xlist.readLine()
- if(s ~= nil) then
- x = split(s)
- else
- break
- end
- end
- xlist.close()
- xlist = fs.open("listed","a")
- else
- xlist = fs.open("listed","w")
- end
- xlist.writeLine(name..","..mine..","..flag..","..drop..","..vein)
- xlist.close()
- return true
- end
- function lstToTable()
- if(fs.exists("listed")) then
- ifile = fs.open("listed","r")
- xlist = {}
- x = split(ifile.readLine())
- while(x ~= nil and x ~= "") do
- table.insert(xlist, x)
- x = split(ifile.readLine())
- end
- else
- -- name,mine,flag,drop,vein
- xlist = {
- {'iron_ore','1','0','0','1'},
- {'coal_ore','1','0','0','1'},
- {'gold_ore','1','0','0','1'},
- {'lapis_ore','1','0','0','1'},
- {'redstone_ore','1','0','0','1'},
- {'diamond_ore','1','0','0','1'},
- {'quartz_ore','1','0','0','1'},
- {'emerald_ore','1','0','0','1'}
- }
- for k,v in pairs(xlist) do
- addList(v[1],v[2],v[3],v[4],v[5])
- end
- end
- return xlist
- end
- lstToTable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement