SHOW:
|
|
- or go back to the newest paste.
| 1 | disc = peripheral.wrap("bottom")
| |
| 2 | mon = peripheral.wrap("top")
| |
| 3 | - | cash = 100 |
| 3 | + | mon.clear() |
| 4 | mon.setCursorPos(1,1) | |
| 5 | - | print("Press Spacebar to play and E to exit")
|
| 5 | + | side = "back" |
| 6 | ||
| 7 | function disk() | |
| 8 | - | print("YOU WON!!!")
|
| 8 | + | os.pullEvent("disk")
|
| 9 | if disc.getLabel() == "SLOTS" and fs.exists("disk/.slots") == true then
| |
| 10 | local file = fs.open("disk/.slots", "r")
| |
| 11 | if file then | |
| 12 | - | print("YOU LOST")
|
| 12 | + | tokens = file.readLine() |
| 13 | file.close() | |
| 14 | end | |
| 15 | end | |
| 16 | disc.eject() | |
| 17 | mon.clear() | |
| 18 | end | |
| 19 | ||
| 20 | - | term.setCursorPos(2,2) |
| 20 | + | |
| 21 | - | print("Cash: "..cash.." ")
|
| 21 | + | |
| 22 | ||
| 23 | - | local event, key = os.pullEvent("char")
|
| 23 | + | |
| 24 | - | if key == "e" then |
| 24 | + | mon.write("YOU WON!!!")
|
| 25 | - | term.clear() |
| 25 | + | |
| 26 | - | return |
| 26 | + | |
| 27 | - | elseif cash <= 0 then |
| 27 | + | |
| 28 | - | local x = 10 |
| 28 | + | mon.write("YOU LOST ")
|
| 29 | end | |
| 30 | - | term.clear() |
| 30 | + | |
| 31 | - | term.setCursorPos(1,5) |
| 31 | + | c1 = colors.white |
| 32 | - | print("Sorry you are out of cash please")
|
| 32 | + | c2 = colors.orange |
| 33 | - | print("start a new game.")
|
| 33 | + | c3 = colors.magenta |
| 34 | - | x = x - 1 |
| 34 | + | c4 = colors.lightBlue |
| 35 | - | print(x) |
| 35 | + | c5 = colors.yellow |
| 36 | c6 = colors.lime | |
| 37 | c7 = colors.pink | |
| 38 | - | return |
| 38 | + | c8 = colors.gray |
| 39 | c9 = colors.lightGray | |
| 40 | c10 = colors.cyan | |
| 41 | c11 = colors.purple | |
| 42 | c12 = colors.blue | |
| 43 | - | term.setCursorPos(1,1) |
| 43 | + | c13 = colors.brown |
| 44 | - | if line == 0 then |
| 44 | + | c14 = colors.green |
| 45 | - | print(line1) |
| 45 | + | c15 = colors.red |
| 46 | c16 = colors.black | |
| 47 | - | else |
| 47 | + | |
| 48 | - | print(line2) |
| 48 | + | |
| 49 | line2 = " -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
| 50 | - | end |
| 50 | + | line = 0 |
| 51 | - | term.setCursorPos(1,17) |
| 51 | + | |
| 52 | - | if line == 0 then |
| 52 | + | |
| 53 | - | print(line2) |
| 53 | + | mon.clear() |
| 54 | - | else |
| 54 | + | mon.setCursorPos(1,1) |
| 55 | - | print(line1) |
| 55 | + | mon.write(line1) |
| 56 | - | end |
| 56 | + | mon.setCursorPos(1,17) |
| 57 | mon.write(line2) | |
| 58 | - | a = math.random(9) |
| 58 | + | mon.setCursorPos(2,2) |
| 59 | - | b = math.random(9) |
| 59 | + | mon.write("Tokens: "..tokens.." ")
|
| 60 | - | c = math.random(9) |
| 60 | + | mon.setCursorPos(5,9) |
| 61 | mon.write("PLEASE ENTER TOKENS TO PLAY")
| |
| 62 | - | term.setCursorPos(20,9) |
| 62 | + | disk() |
| 63 | - | print(a.." - "..b.." - "..c) |
| 63 | + | for i=1,tokens do |
| 64 | sleep(1) | |
| 65 | rs.setBundledOutput("back", 0)
| |
| 66 | mon.setCursorPos(2,2) | |
| 67 | - | term.setCursorPos(20,9) |
| 67 | + | tokens = tokens - 1 |
| 68 | - | print(a.." - "..b.." - "..c) |
| 68 | + | mon.write("Tokens: "..tokens.." ")
|
| 69 | - | print() |
| 69 | + | |
| 70 | - | term.setCursorPos(20,7) |
| 70 | + | |
| 71 | mon.setCursorPos(1,1) | |
| 72 | - | if a == b and b == c then |
| 72 | + | if line == 0 then |
| 73 | mon.write(line1) | |
| 74 | - | if b == 9 then |
| 74 | + | |
| 75 | - | cash = cash + 500 |
| 75 | + | |
| 76 | - | elseif b >= 5 then |
| 76 | + | mon.write(line2) |
| 77 | - | cash = cash + 100 |
| 77 | + | |
| 78 | - | else |
| 78 | + | |
| 79 | - | cash = cash + 25 |
| 79 | + | mon.setCursorPos(1,17) |
| 80 | - | end |
| 80 | + | if line == 0 then |
| 81 | - | elseif a == b or b == c then |
| 81 | + | mon.write(line2) |
| 82 | else | |
| 83 | - | if b == 9 then |
| 83 | + | mon.write(line1) |
| 84 | - | cash = cash + 25 |
| 84 | + | |
| 85 | - | elseif b >= 5 then |
| 85 | + | |
| 86 | - | cash = cash + 10 |
| 86 | + | a = math.random(8) |
| 87 | - | else |
| 87 | + | b = math.random(8) |
| 88 | - | cash = cash + 5 |
| 88 | + | c = math.random(8) |
| 89 | - | end |
| 89 | + | |
| 90 | mon.setCursorPos(10,9) | |
| 91 | mon.write(a.." - "..b.." - "..c) | |
| 92 | - | cash = cash - 5 |
| 92 | + | |
| 93 | end | |
| 94 | - | term.setCursorPos(1,18) |
| 94 | + | |
| 95 | - | end |
| 95 | + | mon.setCursorPos(10,9) |
| 96 | mon.write(a.." - "..b.." - "..c) | |
| 97 | mon.setCursorPos(10,7) | |
| 98 | ||
| 99 | if a == b and b == c then | |
| 100 | won() | |
| 101 | if b == 8 then | |
| 102 | rs.setBundledOutput(side, c1) | |
| 103 | elseif b == 7 then | |
| 104 | rs.setBundledOutput(side, c2) | |
| 105 | elseif b == 6 then | |
| 106 | rs.setBundledOutput(side, c3) | |
| 107 | elseif b == 5 then | |
| 108 | rs.setBundledOutput(side, c4) | |
| 109 | elseif b == 4 then | |
| 110 | rs.setBundledOutput(side, c5) | |
| 111 | elseif b == 3 then | |
| 112 | rs.setBundledOutput(side, c6) | |
| 113 | elseif b == 2 then | |
| 114 | rs.setBundledOutput(side, c7) | |
| 115 | elseif b == 1 then | |
| 116 | rs.setBundledOutput(side, c8) | |
| 117 | end | |
| 118 | elseif a == b or b == c then | |
| 119 | won() | |
| 120 | if b == 8 then | |
| 121 | rs.setBundledOutput(side, c9) | |
| 122 | elseif b == 7 then | |
| 123 | rs.setBundledOutput(side, c10) | |
| 124 | elseif b == 6 then | |
| 125 | rs.setBundledOutput(side, c11) | |
| 126 | elseif b == 5 then | |
| 127 | rs.setBundledOutput(side, c12) | |
| 128 | elseif b == 4 then | |
| 129 | rs.setBundledOutput(side, c13) | |
| 130 | elseif b == 3 then | |
| 131 | rs.setBundledOutput(side, c14) | |
| 132 | elseif b == 2 then | |
| 133 | rs.setBundledOutput(side, c15) | |
| 134 | elseif b == 1 then | |
| 135 | rs.setBundledOutput(side, c16) | |
| 136 | end | |
| 137 | else | |
| 138 | lost() | |
| 139 | end | |
| 140 | sleep(2) | |
| 141 | end | |
| 142 | end |