SHOW:
|
|
- or go back to the newest paste.
| 1 | --For Use With OpenComputers-- | |
| 2 | --Created By Tal_Pal-- | |
| 3 | --Enjoy-- | |
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 | ||
| 11 | local event=require("event")
| |
| 12 | local sides = require("sides")
| |
| 13 | local component = require("component")
| |
| 14 | local rs = component.redstone | |
| 15 | rs.getInput(sides.forward) | |
| 16 | os.execute("clear")
| |
| 17 | print("-- Press Enter Start --")
| |
| 18 | ||
| 19 | ||
| 20 | local function game() | |
| 21 | ::game:: | |
| 22 | ||
| 23 | ||
| 24 | -------------------- | |
| 25 | -- clear terminal -- | |
| 26 | -------------------- | |
| 27 | ||
| 28 | os.execute("clear")
| |
| 29 | ||
| 30 | -- welcome banner -- | |
| 31 | ||
| 32 | banner = string.format[[ _______________________________________________ | |
| 33 | // \\ | |
| 34 | || __ __ _ || | |
| 35 | || \ \ / / | | || | |
| 36 | || \ \ /\ / /__| | ___ ___ _ __ ___ ___ || | |
| 37 | || \ \/ \/ / _ \ |/ __/ _ \| '_ ` _ \ / _ \ || | |
| 38 | || \ /\ / __/ | (_| (_) | | | | | | __/ || | |
| 39 | || \/ \/ \___|_|\___\___/|_| |_| |_|\___| || | |
| 40 | \\_____________________________________________//]] | |
| 41 | ||
| 42 | print(banner) | |
| 43 | ||
| 44 | ----------------------- | |
| 45 | -- Slot Machine code -- | |
| 46 | ----------------------- | |
| 47 | ||
| 48 | x = math.random(7) | |
| 49 | y = math.random(7) | |
| 50 | z = math.random(7) | |
| 51 | ||
| 52 | -- Slot Symbols -- | |
| 53 | ||
| 54 | aa = string.format[[ ]] | |
| 55 | ab = string.format[[ ______ ]] | |
| 56 | ac = string.format[[ |____ | ]] | |
| 57 | ad = string.format[[ / / ]] | |
| 58 | ae = string.format[[ / / ]] | |
| 59 | af = string.format[[ / / ]] | |
| 60 | ag = string.format[[ /_/ ]] | |
| 61 | ||
| 62 | ba = string.format[[ ]] | |
| 63 | bb = string.format[[ _ ]] | |
| 64 | bc = string.format[[| | ]] | |
| 65 | bd = string.format[[| |__ __ _ _ _ ]] | |
| 66 | be = string.format[[| '_ \ / _` | '_|]] | |
| 67 | bf = string.format[[| |_) | (_| | | ]] | |
| 68 | bg = string.format[[|_.__/ \__,_|_| ]] | |
| 69 | ||
| 70 | ca = string.format[[ /\ ]] | |
| 71 | cb = string.format[[ ____/ \____ ]] | |
| 72 | cc = string.format[[ \ / ]] | |
| 73 | cd = string.format[[ > < ]] | |
| 74 | ce = string.format[[ /___ ___\ ]] | |
| 75 | cf = string.format[[ \ / ]] | |
| 76 | cg = string.format[[ \/ ]] | |
| 77 | ||
| 78 | da = string.format[[ ]] | |
| 79 | db = string.format[[ \VW/ ]] | |
| 80 | dc = string.format[[ .::::::. ]] | |
| 81 | dd = string.format[[ :::::::: ]] | |
| 82 | de = string.format[[ '::::::' ]] | |
| 83 | df = string.format[[ '::::' ]] | |
| 84 | dg = string.format[[ `"` ]] | |
| 85 | ||
| 86 | ea = string.format[[ ]] | |
| 87 | eb = string.format[[ ]] | |
| 88 | ec = string.format[[ ". ,# ]] | |
| 89 | ed = string.format[[ \ `-._____,-'=/ ]] | |
| 90 | ee = string.format[[ `._ ----- _,' ]] | |
| 91 | ef = string.format[[ `-----' ]] | |
| 92 | eg = string.format[[ ]] | |
| 93 | ||
| 94 | fa = string.format[[ ]] | |
| 95 | fb = string.format[[ _______ ]] | |
| 96 | fc = string.format[[ .'_/_|_\_'. ]] | |
| 97 | fd = string.format[[ \`\ | /`/ ]] | |
| 98 | fe = string.format[[ `\\ | //' ]] | |
| 99 | ff = string.format[[ `\|/` ]] | |
| 100 | fg = string.format[[ ` ]] | |
| 101 | ||
| 102 | ga = string.format[[ ( ) ]] | |
| 103 | gb = string.format[[ /'_ \ ]] | |
| 104 | gc = string.format[[ ( (_(_) ]] | |
| 105 | gd = string.format[[ \__ \ ]] | |
| 106 | ge = string.format[[ ( )_) ) ]] | |
| 107 | gf = string.format[[ `\_ _/' ]] | |
| 108 | gg = string.format[[ (_) ]] | |
| 109 | ||
| 110 | -- symbol imput to Machine Squares | |
| 111 | ||
| 112 | if x == 1 then | |
| 113 | xxa = aa | |
| 114 | xxb = ab | |
| 115 | xxc = ac | |
| 116 | xxd = ad | |
| 117 | xxe = ae | |
| 118 | xxf = af | |
| 119 | xxg = ag | |
| 120 | ||
| 121 | elseif x == 2 then | |
| 122 | xxa = ba | |
| 123 | xxb = bb | |
| 124 | xxc = bc | |
| 125 | xxd = bd | |
| 126 | xxe = be | |
| 127 | xxf = bf | |
| 128 | xxg = bg | |
| 129 | ||
| 130 | elseif x == 3 then | |
| 131 | xxa = ca | |
| 132 | xxb = cb | |
| 133 | xxc = cc | |
| 134 | xxd = cd | |
| 135 | xxe = ce | |
| 136 | xxf = cf | |
| 137 | xxg = cg | |
| 138 | ||
| 139 | elseif x == 4 then | |
| 140 | xxa = da | |
| 141 | xxb = db | |
| 142 | xxc = dc | |
| 143 | xxd = dd | |
| 144 | xxe = de | |
| 145 | xxf = df | |
| 146 | xxg = dg | |
| 147 | ||
| 148 | elseif x == 5 then | |
| 149 | xxa = ea | |
| 150 | xxb = eb | |
| 151 | xxc = ec | |
| 152 | xxd = ed | |
| 153 | xxe = ee | |
| 154 | xxf = ef | |
| 155 | xxg = eg | |
| 156 | ||
| 157 | elseif x == 6 then | |
| 158 | xxa = fa | |
| 159 | xxb = fb | |
| 160 | xxc = fc | |
| 161 | xxd = fd | |
| 162 | xxe = fe | |
| 163 | xxf = ff | |
| 164 | xxg = fg | |
| 165 | ||
| 166 | elseif x == 7 then | |
| 167 | xxa = ga | |
| 168 | xxb = gb | |
| 169 | xxc = gc | |
| 170 | xxd = gd | |
| 171 | xxe = ge | |
| 172 | xxf = gf | |
| 173 | xxg = gg | |
| 174 | end | |
| 175 | ||
| 176 | ||
| 177 | if y == 1 then | |
| 178 | xya = aa | |
| 179 | xyb = ab | |
| 180 | xyc = ac | |
| 181 | xyd = ad | |
| 182 | xye = ae | |
| 183 | xyf = af | |
| 184 | xyg = ag | |
| 185 | elseif y == 2 then | |
| 186 | xya = ba | |
| 187 | xyb = bb | |
| 188 | xyc = bc | |
| 189 | xyd = bd | |
| 190 | xye = be | |
| 191 | xyf = bf | |
| 192 | xyg = bg | |
| 193 | elseif y == 3 then | |
| 194 | xya = ca | |
| 195 | xyb = cb | |
| 196 | xyc = cc | |
| 197 | xyd = cd | |
| 198 | xye = ce | |
| 199 | xyf = cf | |
| 200 | xyg = cg | |
| 201 | elseif y == 4 then | |
| 202 | xya = da | |
| 203 | xyb = db | |
| 204 | xyc = dc | |
| 205 | xyd = dd | |
| 206 | xye = de | |
| 207 | xyf = df | |
| 208 | xyg = dg | |
| 209 | elseif y == 5 then | |
| 210 | xya = ea | |
| 211 | xyb = eb | |
| 212 | xyc = ec | |
| 213 | xyd = ed | |
| 214 | xye = ee | |
| 215 | xyf = ef | |
| 216 | xyg = eg | |
| 217 | elseif y == 6 then | |
| 218 | xya = fa | |
| 219 | xyb = fb | |
| 220 | xyc = fc | |
| 221 | xyd = fd | |
| 222 | xye = fe | |
| 223 | xyf = ff | |
| 224 | xyg = fg | |
| 225 | elseif y == 7 then | |
| 226 | xya = ga | |
| 227 | xyb = gb | |
| 228 | xyc = gc | |
| 229 | xyd = gd | |
| 230 | xye = ge | |
| 231 | xyf = gf | |
| 232 | xyg = gg | |
| 233 | end | |
| 234 | ||
| 235 | ||
| 236 | if z == 1 then | |
| 237 | xza = aa | |
| 238 | xzb = ab | |
| 239 | xzc = ac | |
| 240 | xzd = ad | |
| 241 | xze = ae | |
| 242 | xzf = af | |
| 243 | xzg = ag | |
| 244 | elseif z == 2 then | |
| 245 | xza = ba | |
| 246 | xzb = bb | |
| 247 | xzc = bc | |
| 248 | xzd = bd | |
| 249 | xze = be | |
| 250 | xzf = bf | |
| 251 | xzg = bg | |
| 252 | elseif z == 3 then | |
| 253 | xza = ca | |
| 254 | xzb = cb | |
| 255 | xzc = cc | |
| 256 | xzd = cd | |
| 257 | xze = ce | |
| 258 | xzf = cf | |
| 259 | xzg = cg | |
| 260 | elseif z == 4 then | |
| 261 | xza = da | |
| 262 | xzb = db | |
| 263 | xzc = dc | |
| 264 | xzd = dd | |
| 265 | xze = de | |
| 266 | xzf = df | |
| 267 | xzg = dg | |
| 268 | elseif z == 5 then | |
| 269 | xza = ea | |
| 270 | xzb = eb | |
| 271 | xzc = ec | |
| 272 | xzd = ed | |
| 273 | xze = ee | |
| 274 | xzf = ef | |
| 275 | xzg = eg | |
| 276 | elseif z == 6 then | |
| 277 | xza = fa | |
| 278 | xzb = fb | |
| 279 | xzc = fc | |
| 280 | xzd = fd | |
| 281 | xze = fe | |
| 282 | xzf = ff | |
| 283 | xzg = fg | |
| 284 | elseif z == 7 then | |
| 285 | xza = ga | |
| 286 | xzb = gb | |
| 287 | xzc = gc | |
| 288 | xzd = gd | |
| 289 | xze = ge | |
| 290 | xzf = gf | |
| 291 | xzg = gg | |
| 292 | end | |
| 293 | ||
| 294 | -- Slots Output | |
| 295 | --17 accross 8 down | |
| 296 | ||
| 297 | q = string.format[[ _________________ _________________ _________________ | |
| 298 | |]] ..xxa.. [[||]] ..xya.. [[||]] ..xza.. [[| | |
| 299 | |]] ..xxb.. [[||]] ..xyb.. [[||]] ..xzb.. [[| | |
| 300 | |]] ..xxc.. [[||]] ..xyc.. [[||]] ..xzc.. [[| | |
| 301 | |]] ..xxd.. [[||]] ..xyd.. [[||]] ..xzd.. [[| | |
| 302 | |]] ..xxe.. [[||]] ..xye.. [[||]] ..xze.. [[| | |
| 303 | |]] ..xxf.. [[||]] ..xyf.. [[||]] ..xzf.. [[| | |
| 304 | |]] ..xxg.. [[||]] ..xyg.. [[||]] ..xzg.. [[| | |
| 305 | |_________________||_________________||_________________|]] | |
| 306 | ||
| 307 | ||
| 308 | jackpot = string.format[[ ___________________________________________________ | |
| 309 | | _ _____ _ _______ ____ _______ | | |
| 310 | | | | /\ / ____| |/ / __ \ / __ \__ __| | | |
| 311 | | | | / \ | | | ' /| |__) | | | | | | | | |
| 312 | | _ | |/ /\ \| | | < | ___/| | | | | | | | |
| 313 | | | |__| / ____ \ |____| . \| | | |__| | | | | | |
| 314 | | \____/_/ \_\_____|_|\_\_| \____/ |_| | | |
| 315 | |___________________________________________________|]] | |
| 316 | ||
| 317 | loose = string.format[[ ___________________________________________________ | |
| 318 | | __ ______ _ _ _ ____ _____ ______ | | |
| 319 | | \ \ / / __ \| | | | | / __ \ / ____| ____| | | |
| 320 | | \ \_/ / | | | | | | | | | | | (___ | |__ | | |
| 321 | | \ /| | | | | | | | | | | |\___ \| __| | | |
| 322 | | | | | |__| | |__| | |___| |__| |____) | |____ | | |
| 323 | | |_| \____/ \____/|______\____/|_____/|______| | | |
| 324 | |___________________________________________________|]] | |
| 325 | ||
| 326 | ||
| 327 | ||
| 328 | ||
| 329 | print(q) | |
| 330 | ||
| 331 | if x == y and x == z then | |
| 332 | print(jackpot) | |
| 333 | else | |
| 334 | print(loose) | |
| 335 | end | |
| 336 | ||
| 337 | --print ("-- Press Enter To Spin --")
| |
| 338 | ||
| 339 | ||
| 340 | ||
| 341 | ||
| 342 | ||
| 343 | repeat | |
| 344 | red = rs.getInput(sides.forward) | |
| 345 | redstone = rs.getInput(sides.back) | |
| 346 | if redstone == 0 then | |
| 347 | goto next | |
| 348 | end | |
| 349 | until(red ~= 0) | |
| 350 | game() | |
| 351 | ||
| 352 | ||
| 353 | ::next:: | |
| 354 | end | |
| 355 | ||
| 356 | print(xpcall(function() | |
| 357 | while true do | |
| 358 | ||
| 359 | local _,_,_,key=event.pull("key_down")
| |
| 360 | ||
| 361 | red = rs.getInput(sides.forward) | |
| 362 | ||
| 363 | if key==28 then | |
| 364 | game() | |
| 365 | elseif key==16 then | |
| 366 | os.execute("clear")
| |
| 367 | break | |
| 368 | os.execute("clear")
| |
| 369 | end | |
| 370 | end | |
| 371 | end,debug.traceback)) |