SHOW:
|
|
- or go back to the newest paste.
| 1 | --Dice in Computercraft | |
| 2 | --TheCountChuckula | |
| 3 | function clear() | |
| 4 | term.clear() | |
| 5 | term.setCursorPos(1,1) | |
| 6 | end | |
| 7 | math.randomseed(os.time()) | |
| 8 | m = peripheral.wrap("back")
| |
| 9 | dienum = 0 | |
| 10 | while true do | |
| 11 | clear() | |
| 12 | print("Hello, Welcome to DICE!")
| |
| 13 | print("-------------------------------------")
| |
| 14 | print("Please select your die for this roll.")
| |
| 15 | print("-------------------------------------")
| |
| 16 | print("a. Flip a Coin")
| |
| 17 | print("b. 4-Sided")
| |
| 18 | print("c. 6-Sided")
| |
| 19 | print("d. 8-Sided")
| |
| 20 | print("e. 10-Sided")
| |
| 21 | print("f. 20-Sided")
| |
| 22 | print("g. 100-Sided")
| |
| 23 | print("-------------------------------------")
| |
| 24 | - | local event, event = os.pullEvent("char")
|
| 24 | + | |
| 25 | - | if event == "a" then |
| 25 | + | local event, select = os.pullEvent("char")
|
| 26 | if select == "a" then | |
| 27 | - | elseif event == "b" then |
| 27 | + | |
| 28 | elseif select == "b" then | |
| 29 | - | elseif event == "c" then |
| 29 | + | |
| 30 | elseif select == "c" then | |
| 31 | - | elseif event == "d" then |
| 31 | + | |
| 32 | elseif select == "d" then | |
| 33 | - | elseif event == "e" then |
| 33 | + | |
| 34 | elseif select == "e" then | |
| 35 | - | elseif event == "f" then |
| 35 | + | |
| 36 | elseif select == "f" then | |
| 37 | - | elseif event == "g" then |
| 37 | + | |
| 38 | elseif select == "g" then | |
| 39 | dienum = 100 | |
| 40 | else | |
| 41 | shell.run("reboot")
| |
| 42 | end | |
| 43 | for r = 1, 5 do | |
| 44 | for x = 1, 2 do | |
| 45 | local effect = math.random(dienum) | |
| 46 | m.setCursorPos(1,x) | |
| 47 | m.clear() | |
| 48 | m.setTextScale(3) | |
| 49 | if effect < 10 then | |
| 50 | m.write("0")
| |
| 51 | m.write(effect) | |
| 52 | else | |
| 53 | m.write(effect) | |
| 54 | end | |
| 55 | sleep(.05) | |
| 56 | end | |
| 57 | end | |
| 58 | local rint = math.random(dienum) | |
| 59 | m.setCursorPos(1,1) | |
| 60 | m.clear() | |
| 61 | m.setTextScale(3) | |
| 62 | if rint < 10 then | |
| 63 | m.write("0")
| |
| 64 | m.write(rint) | |
| 65 | elseif rint == 100 then | |
| 66 | m.setTextScale(2) | |
| 67 | m.write(rint) | |
| 68 | m.setTextScale(3) | |
| 69 | else | |
| 70 | m.write(rint) | |
| 71 | end | |
| 72 | m.setCursorPos(1,2) | |
| 73 | m.write("^^")
| |
| 74 | end |