Posted 16 September 2013 - 09:25 PM
I am trying to build something that will count the votes it receives over rednet and that works but I have no idea how to have who/what has the most votes go on top. Also when it finishes (Stops the loop) how would I allow it to determine who wins?
y = 0
n = 0
p = 0
t = 0
size = 4 --From 1 to 5
side = "left" --Your monitor
m = peripheral.wrap(side)
m.setTextScale(size) --Sets size
repeat
rednet.open("right")
id, message, distance = rednet.receive()
term.clear()
term.setCursorPos(1,1)
if message == "Yes" then
y = y + 1
t = t + 1
end
if message == "No" then
n = n + 1
t = t + 1
end
if message == "Present" then
p = p + 1
t = t + 1
end
print("Yes: "..y)
print("No: "..n)
print("Present: "..p)
until t > 5