Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Main Function
- function init()
- startup()
- confirm = "n"
- number_of_players = 0
- while confirm ~= "y" do
- number_of_players = getPlayers()
- confirm = confirmPlayers(number_of_players)
- end
- player_names = getPlayerNames(number_of_players)
- people_it = getIt()
- vconfirm = checkValue(people_it,number_of_players)
- if vconfirm == false then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- term.write("Error, invalid numbers")
- sleep(2)
- else
- people_it = tonumber(people_it)
- if people_it ~= 1 then
- whosit = spinGroup(people_it)
- a = table.getn(whosit)
- for i=1,a do
- term.write("Player #"..whosit[i].." -> "..player_names[whosit[i]].." is it!")
- print()
- end
- sleep(3)
- elseif people_it == 1 then
- whosit = spinPlayers(number_of_players,people_it)
- term.write("Player #"..whosit.." -> "..player_names[whosit].." is it!")
- sleep(3)
- elseif people_it == 0 then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- term.write("Invalid Numbers!")
- sleep(3)
- end
- term.clear()
- end
- end
- --Puts the startup screen
- function startup()
- term.clear()
- term.setBackgroundColor(colors.gray)
- _bt = paintutils.loadImage(shell.dir() .. "/teammakerpaint")
- term.setBackgroundColor(colors.gray)
- paintutils.drawImage(_bt,1,1)
- term.setCursorPos(15,1)
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.gray)
- term.write("WHOSIT, 0.2b by TNT_Nolan")
- sleep(2.5)
- term.setBackgroundColor(colors.black)
- end
- --Asks for how many players there will be
- function getPlayers()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- term.write("How many players?")
- term.setTextColor(colors.lime)
- term.setCursorPos(1,2)
- local number_of_players = read()
- tonumber(number_of_players)
- return number_of_players
- end
- function checkValue(a,b)
- if a == b then
- return false
- elseif a == 0 then
- return false
- elseif a ~= b then
- return true
- end
- end
- --Asks how many people will be it
- function getIt()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- term.write("How many people will be it?")
- term.setTextColor(colors.lime)
- term.setCursorPos(1,2)
- local people_it = read()
- tonumber(people_it)
- return people_it
- end
- --Confirms the amount of players they put
- function confirmPlayers(players)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- term.write(number_of_players.." players correct? [y/n]")
- term.setCursorPos(1,2)
- term.setTextColor(colors.lime)
- local confirm = read()
- return confirm
- end
- --Asks for the player's names'
- function getPlayerNames(number_of_players)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- a = {}
- for i=1,number_of_players do
- term.write ("Enter name for Player #"..i..": ")
- a[i]= read()
- end
- return a
- end
- --If the input is only one player it this function will be called
- function spinPlayers(number_of_players)
- local whosit = math.random(1,number_of_players)
- return whosit
- end
- --If the input is more than one players it this function will run
- function spinGroup(number_of_players)
- local peopleit = {}
- for i=1,number_of_players do
- index = math.random(1,number_of_players)
- while (has_value(peopleit,index)) do
- index = math.random(1,number_of_players)
- end
- peopleit[i] = index
- end
- return peopleit
- end
- function has_value(array,item)
- for i=1, table.getn(array) do
- if array[i] == item then
- return true
- end
- return false
- end
- end
- --Call Init
- init()
Advertisement
Add Comment
Please, Sign In to add comment