Advertisement
SirBaconBitz

cmd

May 3rd, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. --Loads up item database
  2.  
  3. local handle = fs.open(".itemdb", "r")
  4. local items = textutils.unserialize(handle.readAll())
  5. handle.close()
  6.  
  7. while true do
  8.  
  9. e, msg, d, b, c = os.pullEvent("chat_command")
  10. bridge.clear()
  11. words = {}
  12. found = false
  13.  
  14.   for word in msg:gmatch('%S+') do
  15.   table.insert(words, word)
  16.   end
  17.   print(msg)
  18.   if msg == "clear" then
  19.     print("clear")
  20.     bridge.clear()
  21.   elseif msg == "update" then
  22.     print("update")
  23.     shell.run("update")
  24.   end
  25.   if words[1] == "check" then
  26.     if string.find(words[2], ":") then
  27.     print("got to if")
  28.       item = {}
  29.       for word in words[2]:gmatch('[^%:]+') do
  30.        table.insert(item, word)
  31.       end
  32.       check(item[1], item[2])
  33.      else
  34.       if tonumber(words[2]) == nil then
  35.         for k,v in pairs(items) do
  36.           print(v.name)
  37.            if v.name == words[2] then
  38.              check(v.id,v.dmg)
  39.              found = true
  40.            end
  41.          end
  42.          if found == false then termerr("Couldn't find "..words[2]) end
  43.        elseif tonumber(words[2]) ~= nil then
  44.         check(words[2], 0)
  45.        end
  46.     end
  47.   end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement