Advertisement
LazerAio

CCFS

Apr 19th, 2023 (edited)
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. textutils.slowPrint("CCFS IS LOADING...")
  2. function Bar(procent,description,barPosX,barPosY,barColor)
  3. term.setCursorPos(barPosX,barPosY)
  4. term.setBackgroundColor(colors.gray)
  5. print(" ",description)
  6. term.setBackgroundColor(barColor)
  7. term.setCursorPos(barPosX,barPosY)
  8. print(string.rep(" ",procent*40))
  9. end
  10. Bar(0.2,"Loading...",1,2,colors.red)
  11. ScrnMX,ScrnMY = term.getSize()
  12. function CenterPrint(str,printY,slow)
  13. if printY == nil then
  14. printY = ScrnMY/2
  15. end
  16. term.setCursorPos(ScrnMX/2-(string.len(str)/2),printY)
  17. if slow == false then
  18. print(str)
  19. elseif slow == true then
  20. textutils.slowPrint(str)
  21. end
  22. end
  23. Bar(0.4,"Loading...",1,2,colors.red)
  24. CenterPrint("Wellcome to CCFS!",3,true)
  25. function Clear(clearColor)
  26. term.setBackgroundColor(clearColor)
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. end
  30. Bar(0.6,"Loading...",1,2,colors.red)
  31. function Menu(title,options,bgColor,slow)
  32. local selOp = 1
  33. CenterPrint(title,1,slow)
  34. while true do
  35. Clear(bgColor)
  36. CenterPrint(title,1,false)
  37. for i=1,#options do
  38. if selOp == i then
  39. CenterPrint("[ "..options[i].." ]",i+2,false)
  40. else
  41. CenterPrint("["..options[i].."]",i+2,false)
  42. end
  43. end
  44. E,K = os.pullEvent("key")
  45. if K == keys.down then
  46. if selOp == #options then
  47. selOp = 1
  48. else
  49. selOp = selOp + 1
  50. end
  51. elseif K == keys.up then
  52. if selOp == 1 then
  53. selOp = #options
  54. else
  55. selOp = selOp - 1
  56. end
  57. elseif K == keys.enter then
  58. return selOp
  59. end
  60. end
  61. end
  62. Bar(0.8,"Loading...",1,2,colors.red)
  63. function MainMenu()
  64. Clear(colors.gray)
  65. local mmsel = Menu("Wellcome to CCFS",{"Fly!","About","Exit"},colors.lightBlue,true)
  66. if mmsel == 1 then
  67. Clear(colors.black)
  68. term.setTextColor(colors.white)
  69. CenterPrint("CCFS, SETUP",1,true)
  70. print("Enter MaxFuelConsumption recommended: 10")
  71. MaxFuelConsumption = tonumber(read())
  72. print("Enter acceletaion recommended: 5")
  73. local acceletaion = tonumber(read())
  74. print("Enter stallSpeed recommended: 5")
  75. local stallSpeed = tonumber(read())
  76. print("Enter terminalVelocity recommended: 560")
  77. local terminalVelocity = tonumber(read())
  78. Clear(colors.black)
  79. CenterPrint("MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity",1,false)
  80. print(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
  81. for i=1,5 do
  82. Bar(i/5,"",1,4,colors.white)
  83. CenterPrint(5-i,3,true)
  84. end
  85. Clear(colors.gray)
  86. Fly(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
  87. elseif mmsel == 2 then
  88. Clear(colors.black)
  89. term.setTextColor(colors.white)
  90. CenterPrint("CCFS is a flight simulator for computercraft!",1,true)
  91. CenterPrint("CCFS may not reflect real world situations",2,true)
  92. CenterPrint("No copyright infringement intended, please dont sue!",4,false)
  93. end
  94. end
  95. Clear(colors.lightBlue)
  96. Bar(1,"Done!",1,2,colors.red)
  97. Bar(0.2,"Loading game functions...",1,3,colors.red)
  98. CenterPrint("Wellcome to CCFS!",4,false)
  99. function Dashboard(fuelLevel,Altitude,Warnings,Throthel,PosX,PosY,GpsX,GpsY,speed)
  100. Clear(colors.gray)
  101. term.setTextColor(colors.red)
  102. CenterPrint(Warnings,1,false)
  103. term.setTextColor(colors.white)
  104. CenterPrint("ALT "..tostring(Altitude),2,false)
  105. local i,j = term.getSize()
  106. Bar(fuelLevel,"",(j/2-20),3,colors.orange)
  107. term.setBackgroundColor(colors.gray)
  108. CenterPrint("THRTL:"..tostring(Throthel),4,false)
  109. CenterPrint("YourY "..PosY.." GpsY "..GpsY,6,false)
  110. CenterPrint("YourX "..PosX.." GpsX "..GpsX,5,false)
  111. CenterPrint("SPD:"..tostring(speed),7,false)
  112. end
  113. Bar(0.4,"Loading game functions...",1,3,colors.red)
  114. function UpdatePos(speed,PosX,PosY,stearingX,stearingY,Pitch,Altitude,stallSpeed)
  115. PosX = stearingX*speed
  116. PosY = stearingY*speed
  117. if speed > stallSpeed then
  118. Altitude = Pitch*speed
  119. else
  120. Altitude = Altitude - 1
  121. end
  122. return PosX,PosY,Altitude
  123. end
  124. Bar(0.6,"Loading game functions...",1,3,colors.red)
  125. function UpdateFuelAndSpeed(fuelLevel,Throthel,MaxFuelConsumption,speed,acceletaion,stallSpeed,terminalVelocity)
  126. fuelLevel = fuelLevel - (Throthel)*MaxFuelConsumption
  127. if speed > stallSpeed then
  128. speed = speed + acceletaion*Throthel
  129. else
  130. speed = speed + acceletaion*Throthel + 2
  131. end
  132. if speed > terminalVelocity then
  133. speed = terminalVelocity
  134. end
  135. return fuelLevel, speed
  136. end
  137. Bar(0.8,"Loading game functions...",1,3,colors.red)
  138. function Fly(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
  139. PosX = 0
  140. PosY = 0
  141. GpsX = math.random(1000,2000)
  142. GpsY = math.random(1000,2000)
  143. local fuelLevel=1
  144. Throthel = 0.75
  145. local speed = 100
  146. StearingX = 0
  147. StearingY = 1
  148. Pitch = 0
  149. Altitude = 500
  150. Dashboard(fuelLevel,Altitude,"Press any button to begin flying!",Throthel,PosX,PosY,GpsX,GpsY,speed)
  151. while true do
  152. E,K = os.pullEvent("key")
  153. if K == keys.w then
  154. Throthel = Throthel + 0.1
  155. elseif K == keys.s then
  156. Throthel = Throthel - 0.1
  157. elseif K == keys.up then
  158. Pitch = Pitch - 1
  159. elseif K == keys.down then
  160. Pitch = Pitch + 1
  161. elseif K == keys.right then
  162. StearingX = StearingX - 1
  163. if StearingX > 0 then
  164. StearingY = 1-StearingX
  165. else
  166. StearingY = 1+StearingX
  167. end
  168. elseif K == keys.left then
  169. StearingX = StearingX + 1
  170. if StearingX > 0 then
  171. StearingY = 1-StearingX
  172. else
  173. StearingY = 1+StearingX
  174. end
  175. elseif K == keys.q then
  176. break
  177. end
  178. if Throthel > 1 then
  179. Throthel = 1
  180. elseif Throthel < -1 then
  181. Throthel = -1
  182. end
  183. if speed < stallSpeed then
  184. Dashboard(fuelLevel,Altitude,"STALLING",Throthel,PosX,PosY,GpsX,GpsY,speed)
  185. elseif Altitude < 150 then
  186. Dashboard(fuelLevel,Altitude,"TERRAIN TERRAIN TERRAIN",Throthel,PosX,PosY,GpsX,GpsY,speed)
  187. else
  188. Dashboard(fuelLevel,Altitude,"",Throthel,PosX,PosY,GpsX,GpsY,speed)
  189. end
  190. fuelLevel,speed = UpdateFuelAndSpeed(fuelLevel,Throthel,MaxFuelConsumption,speed,acceletaion,stallSpeed,terminalVelocity)
  191. PosX,PosY,Altitude = UpdatePos(speed,PosX,PosY,StearingX,StearingY,Pitch,Altitude,stallSpeed)
  192. if fuelLevel < 0 then
  193. break
  194. end
  195. end
  196. Clear(colors.black)
  197. CenterPrint("Game over!",1,true)
  198. end
  199. Bar(1,"Done!",1,3,colors.red)
  200. MainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement