Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local characters = {"`","1","2","3","4","5","6","7","8","9","0","-","=",
- "q","w","e","r","t","y","u","i","o","p","[","]","\\",
- "a","s","d","f","g","h","j","k","l",";","'",
- "z","x","c","v","b","n","m",",",".","/",
- "~","!","@","#","$","%","^","&","*","(",")","_","+",
- "Q","W","E","R","T","Y","U","I","O","P","{","}","|",
- "A","S","D","F","G","H","J","K","L",":",'"',
- "Z","X","C","V","B","N","M","<",">","?"
- }
- local disabled = {}
- local digitnum = 18
- while true do
- local code = ""
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- if #characters > 0 then
- for h=1,#characters do
- write(characters[h]..", ")
- end
- end
- term.setTextColor(colors.gray)
- if #disabled > 0 then
- for h=1,#disabled do
- write(disabled[h]..", ")
- end
- end
- term.setTextColor(colors.white)
- print("\n")
- print("Press any key to enable/disable the character or click on any option below.\n")
- print("Digits: <"..digitnum..">")
- print("Generate Code")
- print("Exit\n")
- local event, button, xPos, yPos = os.pullEvent()
- if event == "char" then
- for g=1,94 do
- if button == characters[g] then
- table.insert(disabled, 1, characters[g])
- table.remove(characters, g)
- elseif button == disabled[g] then
- table.insert(characters, 1, disabled[g])
- table.remove(disabled, g)
- end
- end
- elseif event == "key" then
- if button == 203 then
- if digitnum > 1 then
- digitnum = digitnum - 1
- end
- elseif button == 205 then
- digitnum = digitnum + 1
- end
- elseif event == "mouse_click" then
- if xPos >= 1 and xPos <= 13 and yPos == 12 then
- if #characters > 0 then
- for i=1,digitnum do
- local t = math.ceil(math.random(1,#characters))
- code = code..characters[t]
- end
- print(code)
- else
- print("Can't generate a code. All characters are disabled.")
- end
- print("\nPress any button to continue.")
- local event = os.pullEvent("key")
- elseif xPos >= 1 and xPos <= 4 and yPos == 13 then
- break
- elseif xPos == 9 and yPos == 11 then
- if digitnum > 1 then
- digitnum = digitnum - 1
- end
- elseif xPos == 9+string.len(tostring(digitnum))+1 and yPos == 11 then
- digitnum = digitnum + 1
- end
- end
- end
- shell.run("clear")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement