Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gl = peripheral.wrap("bottom")
- ae = peripheral.wrap("front")
- while true do
- evt, cmd = os.pullEvent("chat_command")
- words = {}
- i = 0
- waiting = false
- for word in string.gmatch(cmd, "%S+") do
- words[i] = word
- i = i + 1
- end
- if words[0] == "getitem" then
- if #words < 1 then
- waiting = false
- os.reboot()
- end
- n = ""
- if #words > 1 then
- for i=1,#words do
- n = n.." "..words[i]
- end
- else
- n = words[1]
- end
- name = string.upper(n)
- names = {}
- ids = {}
- qty = {}
- number = 1
- for k,v in pairs(ae.getAvailableItems()) do
- if string.find(string.upper(v.name),name) then
- names[number] = v.name
- ids[number] = v.id
- qty[number] = v.qty
- number = number + 1
- end
- end
- gl.clear()
- idsl = 0
- for i = 1,#ids do
- if string.len(ids[i]) > idsl then
- idsl = string.len(ids[i])
- end
- end
- qtyl = 0
- for i = 1,#ids do
- if string.len(qty[i]) > qtyl then
- qtyl = string.len(qty[i])
- end
- end
- namesl = 0
- for i = 1,#ids do
- if string.len(names[i]) > namesl then
- namesl = string.len(names[i])
- end
- end
- num = 0
- idslen = idsl * 10
- qtylen = qtyl * 10
- nameslen = namesl * 6
- width = 30 + idslen + qtylen + nameslen
- heigth = (#ids * 10) + 15
- gl.addBox(20,5,width,heigth,40,0.5)
- gl.addText(30,10,"num",0x369de1)
- gl.addText(30 + 30,10,"id",0xf0371e)
- gl.addText(30 + 30 + idslen,10,"qty",0xffc703)
- gl.addText(30 + 30 + idslen + qtylen,10,"name",0x637b4b)
- for i = 1,#names do
- gl.addText(30,20 + num ,string.sub(i,1,string.len(i)),0x369de1)
- gl.addText(30 + 30,20 + num ,string.sub(ids[i],1,string.len(ids[i])),0xf0371e)
- gl.addText(30 + 30 + idslen,20 + num ,string.sub(qty[i],1,string.len(qty[i])),0xffc703)
- gl.addText(30 + 30 + idslen + qtylen,20 + num ,names[i],0x637b4b)
- num = num + 10
- end
- waiting = true
- if waiting then
- evt2, cmd2 = os.pullEvent("chat_command")
- i = 0
- mots = {}
- for mot in string.gmatch(cmd2, "%S+") do
- mots[i] = mot
- i = i + 1
- end
- if mots[0] == "num" then
- cust = {}
- cust["id"] = tonubmer(ids[mots[1]])
- cust["qty"] = tonubmer(mots[2])
- cust["dmg"] = -1
- ae.extractItem(cust, "east")
- gl.clear()
- else
- waiting = false
- gl.clear()
- os.reboot()
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement