Advertisement
NanoBob

NanoShop Item Values

Jul 22nd, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local mainFrame=24
  2.  
  3. rednet.open("right")
  4.  
  5. function checkForItems()
  6.     turtle.suck()
  7.     turtle.select(1)
  8.     local detail=turtle.getItemDetail(1)
  9.     if detail==nil then return end
  10.     local id=detail.name
  11.     repeat
  12.         rednet.send(mainFrame,"getValue,"..id,"NanoShop")
  13.         local i,value=rednet.receive()
  14.         if i==mainFrame then
  15.             if value=="false" then
  16.                 os.setComputerLabel("This item is worthless")
  17.             else
  18.                 os.setComputerLabel("This item is worth "..value.." NanoCredits")
  19.             end
  20.             turtle.select(1)
  21.             turtle.drop()
  22.             sleep(5)
  23.             os.setComputerLabel("Item Values")
  24.         end
  25.     until i==mainFrame
  26. end
  27.  
  28. function setup()
  29.     term.clear()
  30.     term.setCursorPos(1,1)
  31.     print([[Welcome to the NanoTech shop!
  32.    
  33. I will assist you by telling you the values of items. This is the ammount of NanoCredit you get for selling this item at the terminal across from me.
  34.  
  35. Place an item on the ground in front of me and I will analyse and value the item.]])
  36. end
  37. setup()
  38.  
  39.  
  40. while true do
  41.     checkForItems()
  42.     sleep(2)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement