Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local choices = {
- {" Chickens",false,colors.gray},
- {" Blazes",false,colors.yellow},
- {" Endermen",false,colors.black},
- {" Spiders",false,colors.brown},
- {" Creepers",false,colors.green}
- }
- local door = {true, colors.white}
- local size = #choices;
- local totalColor = 0
- for i=1,size do
- totalColor = totalColor + choices[i][3]
- end
- function update()
- cx,cy = term.getCursorPos()
- term.clear()
- term.setCursorPos(1,1)
- for i=1,size do
- if choices[i][2] then
- term.setTextColor(colors.green)
- else
- term.setTextColor(colors.red)
- end
- print(choices[i][1])
- end
- term.setCursorPos(1,size+2)
- term.setTextColor(colors.white)
- if door[1] then
- term.setTextColor(colors.green)
- else
- term.setTextColor(colors.red)
- end
- print(" Door")
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Up/Down to select, Enter to toggle")
- term.setCursorPos(cx,cy)
- signal()
- end
- function signal()
- local output = 0
- if door[1] then
- output = door[2]
- else
- for i=1,size do
- if choices[i][2] then
- output = output-choices[i][3]
- end
- end
- end
- redstone.setBundledOutput("back",totalColor + output)
- end
- term.setCursorBlink(true)
- term.setCursorPos(1,1)
- update()
- while true do
- event, p1 = os.pullEvent()
- x,y = term.getCursorPos()
- if event == "key" then
- if p1 == 28 then-- enter
- if y <= size then
- for i = 1,size do
- if i ~= y then
- choices[i][2] = false
- end
- end
- choices[y][2] = not choices[y][2]
- if choices[y][2] then
- door[1] = false
- end
- elseif y == size+2 then
- door[1] = not door[1]
- if door[1] then
- for i = 1,size do
- choices[i][2] = false
- end
- end
- end
- update()
- elseif p1 == 200 then-- up
- if y - 1 >= 1 then
- term.setCursorPos(x,y-1)
- end
- elseif p1 == 208 then-- down
- if y + 1 <= size+2 then
- term.setCursorPos(x,y+1)
- end
- end
- end
- end
- -- up 200
- -- down 208
- -- enter 28
- --spider
- --chicken
- --blaze
- --endermen
Advertisement
Add Comment
Please, Sign In to add comment