Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- m = peripheral.wrap("top")
- m.clear()
- comp = {
- "Ivan Zarkov", "Bob41599", "Blouwing14", "Dev Eagle", "PlentyOfKills", "N320S", "Kenpokid4", "DizzyAaron", "Jonathan", "Johnathon Chase",
- "TPC", "Ivan Zarkov", "PlentyOfKills", "Artys", "Retschga", "N320S", "Kenpokid4", "Bob41599", "DizzyAaron", "Johnathon Chase",
- "PlentyOfKills", "Ivan Zarkov", "N320S", "DizzyAaron", "Blouwing14", "Retschga", "Kenpokid4", "Johnathon Chase", "Lizy Girl",
- "Kenpokid4", "TheNaeria", "Ivan Zarkov", "PlentyOfKills", "Retschga", "N320S", "DizzyAaron", "TPC", "Darko", "DrTacete", "Johnathon Chase",
- "TPC", "Retschga", "N320S", "PlentyOfKills", "DizzyAaron", "Ivan Zarkov", "DrTacete", "PoOoPiez", "Kenpokid4", "Johnathon Chase",
- "N320S", "PlentyOfKills", "ProRed", "Blouwing14", "DizzyAaron", "RealAlDay1", "Ivan Zarkov", "Retschga", "Ethan Rokosz", "H3ADPH0NEFREAK", "DrTacete", "Habood Hisham", "TPC", "Kenpokid4", "Johnathon Chase",
- "Dan Zavada", "PlentyOfKills", "Ivan Zarkov", "Chris O", "DrTacete", "Nick Dubz", "N320S", "Daniel Stein", "Braiden Allen", "Dan Zavada", "TPC", "Johnathon Chase",
- "Ivan Zarkov", "DrTacete", "Retschga", "PlentyOfKills", "N320S", "Chris O", "Dan Zavada", "DizzyAaron", "Daniel Stein", "MrPriZmaHD", "Kenni Krisensen", "UkrainianGaming", "purplemangaming", "KevinZePanda", "TPC", "LEGOKID", "Johnathon Chase", "Kenpokid4",
- "Ivan Zarkov", "ProRed", "Waynee", "PlentyOfKills", "DrTacete", "Dan Zavada", "Retschga", "Daniel Stein", "TPC", "DizzyAaron", "alexmendiger", "Francisco", "Johnathon Chase", "Kenpokid4", "N320S", "Kenni Krisensen", "TiMBo Mc",
- "Ivan Zarkov", "PlentyOfKills", "Plantago", "Arman Malekloo", "DrTacete", "Waynee", "UkrainianGaming", "Pigmack Gaming", "TheSadegh123", "TPC", "N320S", "Johnathon Chase", "Kenpokid4", "Retschga", "Kenni Krisensen",
- }
- function countArray(t)
- local count = 0
- for _ in pairs(t) do count = count + 1 end
- return count
- end
- comments = countArray(comp)
- function spairs(t, order)
- local keys = {}
- for k in pairs(t) do keys[#keys+1] = k end
- if order then
- table.sort(keys, function(a,b) return order(t, a, b) end)
- else
- table.sort(keys)
- end
- local i = 0
- return function()
- i = i + 1
- if keys[i] then
- return keys[i], t[keys[i]]
- end
- end
- end
- function fillTable()
- button.setTable("Draw Winner", drawWinner, 10,30, 23,25)
- button.screen()
- end
- function groupComp(t)
- local results = {}
- for k, v in pairs(t) do
- if results[v] then
- results[v] = results[v] + 1
- else results[v] = 1
- end
- end
- --table.sort(results)
- return results
- end
- function listCompetitors()
- x = 2
- y = 5
- compsorted = groupComp(comp)
- for k,v in spairs(compsorted, function(t,a,b) return t[b] < t[a] end) do
- x = 2
- m.setCursorPos(x,y)
- m.setTextColor(colors.cyan)
- m.write(k)
- m.setTextColor(colors.yellow)
- m.setCursorPos(25,y)
- m.write(math.floor(v))
- m.setTextColor(colors.white)
- m.setCursorPos(32, y)
- chance = (v / comments)*100
- m.write(math.floor(chance) .. "%")
- y = y + 1
- if y > 18 then break end
- end
- end
- function centerMe(text, rowNum)
- w, h = m.getSize()
- --print("Center Me called, width is..")
- --print(w)
- m.setCursorPos((w-string.len(text))/2 + 1, rowNum)
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function randomSelection(t)
- num = t[ math.random( #t ) ]
- return num
- end
- function drawWinner()
- button.flash("Draw Winner")
- result = randomSelection(comp)
- m.clear()
- headerLine()
- local i = 0
- spinmsg = "Spinning..."
- while i < 20 do
- local num = math.random(1,5)
- if num == 1 then
- m.setTextColor(colors.lime)
- elseif num == 2 then
- m.setTextColor(colors.lightBlue)
- elseif num == 3 then
- m.setTextColor(colors.red)
- elseif num == 4 then
- m.setTextColor(colors.yellow)
- elseif num == 5 then
- m.setTextColor(colors.magenta)
- end
- centerMe(spinmsg, 10)
- m.write(spinmsg)
- sleep(0.5)
- starpos = i + 16
- m.setCursorPos(starpos, 11)
- m.write("*")
- m.setTextColor(colors.white)
- i = i + 1
- end
- m.clear()
- headerLine()
- sleep(1)
- local x = 0
- while x < 5 do
- sleep(0.4)
- centerMe(result, 10)
- m.setTextColor(colors.yellow)
- m.write(result)
- sleep(0.4)
- centerMe(result, 10)
- m.setTextColor(colors.white)
- m.write(result)
- sleep(0.4)
- centerMe(result, 10)
- m.setTextColor(colors.lime)
- m.write(result)
- x = x+1
- --button.screen()
- end
- m.setTextColor(colors.yellow)
- m.setCursorPos(16,12)
- m.write("Cong")
- m.setTextColor(colors.orange)
- m.setCursorPos(20,12)
- m.write("ratul")
- m.setTextColor(colors.red)
- m.setCursorPos(25,12)
- m.write("ations")
- m.setTextColor(colors.white)
- m.setCursorPos(31,12)
- m.write("!!!")
- button.screen()
- end
- fillTable()
- function headerLine()
- m.setTextColor(colors.white)
- m.setTextScale(1)
- button.heading("Iskalls GiveAway Machine")
- m.setCursorPos(1,3)
- m.setTextColor(colors.lime)
- m.write("***************************************************")
- m.setTextColor(colors.white)
- end
- headerLine()
- pCount = "Total Comments: " .. comments
- centerMe(pCount, 20)
- m.write(pCount)
- listCompetitors()
- groupComp(comp)
- --button.label(1,5,"Demo!")
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement