Advertisement
montana_1

shouldMineWhole

Nov 7th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. function split(inputstr, sep)
  2.     if(inputstr == nil or inputstr == "") then
  3.                 return nil
  4.         end
  5.         if sep == nil then
  6.                 sep = ","
  7.         end
  8.         local t={} ; i=1
  9.         for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  10.                 t[i] = str
  11.                 i = i + 1
  12.         end
  13.         return t
  14. end
  15.  
  16. function shouldMineWhole(istr,xlist)
  17.     for key,value in pairs(xlist) do
  18.         if(istr == value[1] and value[5] == "1") then
  19.             return true
  20.         end
  21.     end
  22.     return false
  23. end
  24.  
  25.  
  26. if(fs.exists("listed")) then
  27.     ifile = fs.open("listed","r")
  28.     xlist = {}
  29.     x = split(ifile.readLine(),',')
  30.     while(x ~= nil and x ~= "") do
  31.         table.insert(xlist, x)
  32.         x = split(ifile.readLine(),',')
  33.     end
  34. else
  35.     print("Listed file does not exist, cannot clear inventory")
  36. end
  37.  
  38. x = read()
  39. print(shouldMineWhole(x,xlist))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement