Advertisement
Guest User

startup

a guest
Aug 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local chests = {}
  2. chests[1] = {["name"]="Bram",["c1"]=colors.green,["c2"]=colors.red,["c3"]=colors.blue}
  3. chests[2] = {["name"]="Stefan",["c1"]=colors.blue,["c2"]=colors.pink,["c3"]=colors.green}
  4.  
  5. function readInt()
  6.    local r = read()
  7.    local n = tonumber(r)
  8.    while( n == nil ) do
  9.      print(r.." is not a number")
  10.      r = read()
  11.      n = tonumber(r)
  12.    end
  13.    return n
  14. end
  15.  
  16. local sign = peripheral.wrap("top")
  17. local c, lastChest
  18. while true do
  19.   for key,data in pairs(chests) do
  20.     print(key..". "..data.name)
  21.   end
  22.   if lastChest ~= nil then
  23.     print((#chests+1)..". Last used chest: "..lastChest.name)
  24.   end
  25.  
  26.   local choice = readInt()
  27.   lastChest = c
  28.   c = chests[choice]
  29.   local ender = peripheral.wrap("left")
  30.   ender.setColors(c.c1, c.c2, c.c3)
  31.   print("Changed chest to "..c.name)
  32.   print()
  33.   if sign ~= nil then
  34.     sign.setLine(1, "Current chest: ")
  35.     sign.setLine(2, c.name)
  36.     if lastChest ~= nil then
  37.       sign.setLine(3, "Last chest: ")
  38.       sign.setLine(4, lastChest.name)
  39.     end
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement