Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local screenx, screeny = term.getSize()
- local cards = 15
- local tcards = 15
- local tArgs = {...}
- if #tArgs < 2 then
- print("Usage: "..shell.getRunningProgram().." <warcards> <layside> [warsoundside] [normalsoundside]")
- print("Please insure both sound sides are top, bottom, left, right, back, or front.")
- print('The lay side is what side to receive redstone input to "lay a card" (options same as sound sides)')
- else
- local s1 = tArgs[4] or "bottom"
- local s2 = tArgs[3] or "bottom"
- local layside = tArgs[2]
- local function genericSound()
- redstone.setOutput(s1, true)
- sleep(0.1)
- redstone.setOutput(s1, false)
- end
- local function warSound()
- redstone.setOutput(s2, true)
- sleep(0.1)
- redstone.setOutput(s2, false)
- end
- term.clear()
- term.setCursorPos(1, 1)
- local warcards = tArgs[1]
- while true do
- term.clear()
- term.setBackgroundColor(colors.black)
- if cards < 1 then
- term.setCursorPos(1,1)
- print("You lost War!")
- genericSound()
- break
- elseif tcards < 1 then
- term.setCursorPos(1,1)
- print("You beat War!")
- warSound()
- break
- end
- term.setCursorPos(35,1)
- print("Your cards: "..cards.."")
- term.setCursorPos(35,2)
- print("Their cards: "..tcards.."")
- term.setCursorPos(1,1)
- local yourcard = math.random(1,11)
- local theircard = math.random(1,11)
- print("Lay a card")
- while not redstone.getInput(layside) do
- end
- print("3")
- sleep(1)
- print("2")
- sleep(1)
- print("1")
- sleep(1)
- print("Go!")
- if yourcard == 11 and theircard == 11 then
- print("You have Ace. They have Ace.")
- elseif yourcard ~= 11 and theircard ~= 11 then
- print("You have "..yourcard..". They have "..theircard.."")
- elseif yourcard == 11 then
- print("You have Ace. They have "..theircard.."")
- elseif theircard == 11 then
- print("You have "..yourcard..". They have Ace.")
- end
- if yourcard > theircard then
- cards = cards + 1
- tcards = tcards - 1
- print("You win!")
- genericSound()
- paintutils.drawPixel(screenx/2,screeny/2,colors.white)
- term.setBackgroundColor(colors.black)
- event, button, x, y = os.pullEvent("mouse_click")
- if x == screenx/2 and y == screeny/2 then
- term.setBackgroundColor(colors.black)
- paintutils.drawPixel(screenx/2,screeny/2, colors.black)
- term.setbackgroundColor(colors.black)
- end
- elseif theircard > yourcard then
- cards = cards - 1
- tcards = tcards + 1
- print("They win!")
- genericSound()
- paintutils.drawPixel(screenx/2,screeny/2,colors.white)
- term.setBackgroundColor(colors.black)
- event, button, x, y = os.pullEvent("mouse_click")
- if x == screenx/2 and y == screeny/2 then
- term.setBackgroundColor(colors.black)
- paintutils.drawPixel(screenx/2,screeny/2,colors.black)
- term.setBackgroundColor(colors.black)
- end
- elseif theircard == yourcard then
- function war(times)
- local times = times or 1
- print("War!")
- sleep(0.1)
- warSound()
- print("Lay a card")
- while not redstone.getInput(layside) do
- end
- local wyourcard = math.random(1,11)
- local wtheircard = math.random(1,11)
- if wyourcard == 11 and wtheircard == 11 then
- print("You have Ace. They have Ace.")
- elseif wyourcard ~= 11 and wtheircard ~= 11 then
- print("You have "..wyourcard..". They have "..wtheircard.."")
- elseif wyourcard == 11 then
- print("You have Ace. They have "..wtheircard.."")
- elseif wtheircard == 11 then
- print("You have "..wyourcard..". They have Ace.")
- end
- if wyourcard > wtheircard then
- tcards = tcards - 3+1*times
- cards = cards + 3+1*times
- print("You win!")
- paintutils.drawPixel(screenx/2,screeny/2-2,colors.white)
- term.setBackgroundColor(colors.black)
- event, button, x, y = os.pullEvent("mouse_click")
- if x == screenx/2 and y == screeny/2 then
- term.setBackgroundColor(colors.black)
- paintutils.drawPixel(screenx/2,screeny/2-2,colors.black)
- term.setBackgroundColor(colors.black)
- end
- elseif wtheircard > wyourcard then
- tcards = tcards + 3 + 1 * times
- cards = cards - 3 + 1 * times
- print("They win!")
- paintutils.drawPixel(screenx/2,screeny/2-2,colors.white)
- term.setBackgroundColor(colors.black)
- event, button, x, y= os.pullEvent("mouse_click")
- if x == screenx/2 and y == screeny/2 then
- term.setBackgroundColor(colors.black)
- paintutils.drawPixel(screenx/2,screeny/2-2,colors.black)
- term.setBackgroundColor(colors.black)
- end
- elseif wtheircard == wyourcard then
- war(times+1)
- end
- end
- war()
- end
- end
- end
Add Comment
Please, Sign In to add comment