Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- w,h = term.getSize()
- modemside = "top"
- function clear()
- term.clear()
- end
- function write(str,xpos,ypos)
- term.setCursorPos(xpos,ypos)
- term.write(str)
- end
- function printCenter(str,ypos)
- term.setCursorPos(w/2 - #str/2,ypos)
- term.write(str)
- end
- function header(str)
- printCenter(string.rep("-",w),1)
- printCenter(str,3)
- printCenter(string.rep("-",w),5)
- end
- function connect()
- clear()
- term.setTextColor(colors.lime)
- header("<VOTING BOOTH>")
- term.setTextColor(colors.yellow)
- printCenter("<Please click the block below this terminal.>",10)
- ev,user = os.pullEvent("player")
- end
- while true do
- rednet.open(modemside)
- connect()
- clear()
- rednet.broadcast("needvoter")
- sleep(.1)
- rednet.broadcast(user)
- ev,p1,p2,p3 = os.pullEvent("rednet_message")
- if p2 == "yes" then
- term.setTextColor(colors.red)
- header("<YOU CAN NOT VOTE>")
- term.setTextColor(colors.orange)
- printCenter("You have already voted "..user..".",10)
- sleep(3)
- elseif p2 == "no" then
- term.setTextColor(colors.lime)
- header("<PLACE YOUR VOTE>")
- term.setTextColor(colors.yellow)
- printCenter("Press 'a' to vote for the left option, and",10)
- printCenter("press 'b' to vote for the right option.",11)
- ev,p1,p2,p3 = os.pullEvent("char")
- if p1 == "a" then
- rednet.broadcast("vote1")
- elseif p1 == "b" then
- rednet.broadcast("vote2")
- end
- rednet.broadcast("newvoter")
- sleep(.1)
- rednet.broadcast(user)
- clear()
- term.setTextColor(colors.lime)
- header("<VOTE SENT>")
- term.setTextColor(colors.yellow)
- printCenter("Thanks for voting!",8)
- sleep(3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement