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