Advertisement
Rolcam

[WIP] Computercraft Boss Fight Timer

Feb 22nd, 2022 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.16 KB | None | 0 0
  1. -- Designed for PvE fights, not PvP
  2. -- Change this to whatever the sensor peripheral is connected as
  3. sensor = peripheral.wrap("openperipheral_sensor_0")
  4. -- Change this to whatever the monitor is connected as
  5. mon = peripheral.wrap("monitor_75")
  6. -- rednet side
  7. rSide = "right"
  8. -- Fight Status
  9. fight = false
  10. -- Timer Data
  11. tData = 0
  12. -- Name of the boss
  13. mobName = " "
  14. -- Fight Results
  15. fRes = " "
  16. -- Player attempts
  17. attempts = 1
  18.  
  19. iLoop = 1
  20. iLoop2 = 1
  21. while iLoop == 1 do
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.     term.setTextColor(colors.orange)
  25.     print("Program Setup")
  26.     print("Please enter the player's name:")
  27.     iLoop2 = 1
  28.     pData = read()
  29.     while iLoop2 == 1 do
  30.         term.clear()
  31.         term.setCursorPos(1,1)
  32.         term.setTextColor(colors.orange)
  33.         print("Program Setup")
  34.         print(pData .. " - Is this correct? y/n")
  35.         input = read()
  36.         if input == "y" or input == "Y" or input == "yes" or input == "YES" or input == "yes" then
  37.             print("Name Set! Beginning Program")
  38.             sleep(1)
  39.             iLoop2 = 0
  40.             iLoop = 0
  41.         elseif input == "N" or input == "n" or input == "NO" or input == "no" or input == "No" then
  42.             iLoop2 = 0
  43.         else
  44.             term.setTextColor(colors.red)
  45.             print("Invalid Selection")
  46.             sleep(1)
  47.         end
  48.     end
  49. end
  50. while rs.testBundledInput(rSide, colors.orange) == false do
  51.     sleep(0.1)
  52.     term.clear()
  53.     term.setCursorPos(1,1)
  54.     print("Waiting for boss spawn")
  55. end
  56. sleep(4)
  57.     iLoop = 1
  58. loop3 = true
  59. while loop3 == true do
  60.     mData = textutils.serialize(sensor.getMobIds())
  61.     term.clear()
  62.     term.setCursorPos(1,1)
  63.     print("Arena Stat Management System V1 \n ")
  64.     print("Players: ")
  65.     print(pData)
  66.    
  67.     print("Mob Data: ")
  68.     print(mData)
  69.    
  70.     term.redirect(mon)
  71.     term.clear()
  72.     term.setCursorPos(1,1)
  73.     term.setTextColor(colors.lime)
  74.     print("Boss Fight in Progress! Keep clear of the arena! \n ")
  75.     term.setTextColor(colors.orange)
  76.     print("Player Present: " .. pData)
  77.     print(pData .."'s attempts: " .. attempts)
  78.     print (" ")
  79.     print("Current Boss: " .. mobName .. " \n ")
  80.     print("Timer: " .. tData .. " seconds elapsed")
  81.     sleep(1)
  82.     tData = tData + 1
  83.     term.restore()
  84.    
  85.     if rs.testBundledInput(rSide, colors.white) == true then
  86.         iLoop = 1
  87.         term.redirect(mon)
  88.         term.clear()
  89.         term.setCursorPos(1,1)
  90.         term.setTextColor(colors.yellow)
  91.         print("Boss Fight Paused by Arena Operator - Awaiting input \n ")
  92.         term.setTextColor(colors.orange)
  93.         print("Player Present: " .. pData)
  94.         print(pData .."'s attempts: " .. attempts)
  95.         print (" ")
  96.         print("Current Boss: " .. mobName .. " \n ")
  97.         term.setTextColor(colors.yellow)
  98.         print("Timer: " .. tData .. " seconds elapsed")
  99.         term.restore()
  100.         while iLoop == 1 do
  101.             term.clear()
  102.             term.setCursorPos(1,1)
  103.             term.setTextColor(colors.orange)
  104.             print("Arena Stat Management System V1 \n ")
  105.             print("Fight has been paused!")
  106.             print("Please Input Your Selection: ")
  107.             print("End Fight (Player Loss) - \"Loss\"")
  108.             print("End Fight (Player Won) - \"Won\"")
  109.             print("Resume Fight - \"Resume\"")
  110.             input = read()
  111.             if input == "resume" or input == "Resume" then
  112.                 iLoop = 0
  113.             elseif input == "Loss" or input == "loss" then
  114.                 attempts = attempts + 1
  115.                 if attempts >= 4 then
  116.                     fRes = "Lost"
  117.                     attempts = 3
  118.                     loop3 = false
  119.                 else
  120.                     print("Resuming Match")
  121.                     sleep(1)
  122.                 end
  123.                     iLoop = 0
  124.             elseif input == "Won" or input == "won" then
  125.                 fRes = "Won"
  126.                 loop3 = false
  127.                 iLoop = 0
  128.             else
  129.                 term.setTextColor(colors.red)
  130.                 print("Invalid Selection")
  131.                 sleep(1)
  132.             end
  133.         end
  134.     end
  135. end
  136.  
  137.  
  138.  
  139. print("Fight Ended - Updating Stat Board")
  140. term.redirect(mon)
  141. term.clear()
  142. term.setCursorPos(1,1)
  143. term.setTextColor(colors.red)
  144. if fRes == "Won" then
  145.     term.setTextColor(colors.lime)
  146.     print("Boss Fight Ended by Arena Operator - Results Below! \n ")
  147. else
  148.     term.setTextColor(colors.red)
  149.     print("Boss Fight Ended by Automated System - Results Below! \n ")
  150. end
  151. term.setTextColor(colors.orange)
  152. print("Player Present: " .. pData)
  153. if fRes == "Won" then
  154.     term.setTextColor(colors.yellow)
  155.     print(pData .."'s attempts: " .. attempts)
  156. else
  157.     term.setTextColor(colors.red)
  158.     print(pData .." used up their 3 attempts. Game over")
  159. end
  160. print (" ")
  161. print("Current Boss: " .. mobName .. " \n ")
  162. if fRes == "Won" then
  163.     term.setTextColor(colors.yellow)
  164. else
  165.     term.setTextColor(colors.red)
  166. end
  167. print("Timer: " .. tData .. " seconds elapsed")
  168. if fRes == "Won" then
  169.     term.setTextColor(colors.lime)
  170.     print(pData .. " has won the fight! Payouts will begin shortly.")
  171. else
  172.     term.setTextColor(colors.red)
  173.     print(pData .. " has lost the fight. Bets have been forfeited.")
  174. end
  175. term.restore()
  176. -- Change this to the name of the stat program
  177. shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement