Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Logo]]--
- local logo = {
- " _____ _ _ _____ _ _ ",
- "| | |_|___| |_ | __ |___| | |___ ___ ",
- "| | | . | | | -| . | | | -_| _|",
- "|__|__|_|_ |_|_| |__|__|___|_|_|___|_| ",
- " |___| ",
- " _____ ",
- "| __ |_ _ ",
- "| __ -| | |",
- "|_____|_ |",
- " |___|",
- " _____ _ _ _ _ _____ _____ ____ ",
- " | __|_ _|_|___|_|_| |___| | __|_ _| \\ ___ ",
- " |__ | | | | _| | . | .'| |__ | | | | | |- _|",
- " |_____|___|_|___|_|___|__,|_|_____| |_| |____/|___|"
- }
- --[[Define the dice in a table]]--
- local dice = {
- [1] = {
- "*-------*",
- "| |",
- "| * |",
- "| |",
- "*-------*"
- },
- [2] = {
- "*-------*",
- "| * |",
- "| |",
- "| * |",
- "*-------*"
- },
- [3] = {
- "*-------*",
- "| * |",
- "| * |",
- "| * |",
- "*-------*"
- },
- [4] = {
- "*-------*",
- "| * * |",
- "| |",
- "| * * |",
- "*-------*"
- },
- [5] = {
- "*-------*",
- "| * * |",
- "| * |",
- "| * * |",
- "*-------*"
- },
- [6] = {
- "*-------*",
- "| * * |",
- "| * * |",
- "| * * |",
- "*-------*"
- }
- }
- --[[Get the width and height of the terminal/screen]]--
- local w,h = term.getSize()
- --[[Define the varaible 'win']]--
- local wins = 0
- --[[Define a 'center text' function]]--
- local function center(text,y)
- term.setCursorPos(((w-#text)/2)+1,y)
- term.write(text)
- end
- --[[Defining a function to print the logo]]--
- local function printLogo()
- term.clear()
- term.setCursorPos(1,1)
- local y = (h/5)
- local diff = y
- for _,v in pairs(logo) do
- center(v,diff)
- diff = (diff+1)
- end
- sleep(3)
- end
- --[[Define a function to catch any errors]]--
- local function err(path)
- local ok,err = pcall(path)
- if not ok then
- term.clear()
- center("An error has occured!",1)
- center(err,h/2)
- center("Press any key to continue",h)
- end
- os.pullEvent("key")
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- --[[Define the 'dice roll' function]]--
- local function roll()
- while true do
- repeat
- local y = (h/2)-2
- os.startTimer(0.001)
- ev,p1 = os.pullEvent()
- term.clear()
- center("Press the 'tilde' key to stop the dice!",1)
- center("High Roller is coded by SuicidalSTDz!",19)
- center("Wins: "..wins,15)
- randomNum = math.random(1,6)
- for _,v in pairs(dice[randomNum]) do
- term.setCursorPos(((w-9)/2)+1,y)
- term.write(v)
- y = (y+1)
- end
- until ev == "key" and p1 == 41
- if randomNum == 6 then
- wins = (wins+1)
- end
- term.setCursorPos(1,15)
- term.clearLine()
- center("Wins: "..wins,15)
- term.setCursorPos(1,2)
- term.clearLine()
- center("Press any other key to exit",2)
- center("Press the 'tilde' key to roll the dice!",1)
- repeat
- _,p1 = os.pullEvent("key")
- if p1 ~= 41 then
- term.clear()
- term.setCursorPos(1,1)
- os.run({},"rom/programs/shell")
- end
- until p1 == 41
- end
- end
- --[[Print the contents of the table 'logo' using the function I defined earlier]]--
- printLogo()
- --[[Call the 'roll' function]]--
- err(roll)
Advertisement
Add Comment
Please, Sign In to add comment