fork download
  1.  
  2. function init()
  3. storage.complete = storage.complete or false
  4. self.compassUpdate = config.getParameter("compassUpdate", 0.5)
  5. self.descriptions = config.getParameter("descriptions")
  6.  
  7. self.scientistUid = config.getParameter("scientistUid")
  8. self.techstationUid = config.getParameter("techstationUid")
  9.  
  10. self.findRange = config.getParameter("findRange")
  11. self.exploreTime = config.getParameter("exploreTime")
  12. storage.exploreTimer = storage.exploreTimer or 0
  13.  
  14. setPortraits()
  15.  
  16. storage.stage = storage.stage or 1
  17. self.stages = {
  18. explore,
  19. findScientist
  20. }
  21.  
  22. self.state = FSM:new()
  23. self.state:set(self.stages[storage.stage])
  24. end
  25.  
  26. function questInteract(entityId)
  27. if self.onInteract then
  28. return self.onInteract(entityId)
  29. end
  30. end
  31.  
  32. function questStart()
  33. player.upgradeShip(config.getParameter("shipUpgrade"))
  34. end
  35.  
  36. function update(dt)
  37. self.state:update(dt)
  38.  
  39. if storage.complete then
  40. quest.setCanTurnIn(true)
  41. end
  42. end
  43.  
  44. function explore()
  45. quest.setObjectiveList({{self.descriptions.explore, false}})
  46.  
  47. -- Wait until the player is no longer on the ship
  48. local findSci = util.uniqueEntityTracker(self.scientistUid, self.compassUpdate)
  49. local buffer = 0
  50. while storage.exploreTimer < self.exploreTime do
  51. -- quest.setProgress(math.min(storage.exploreTimer / self.exploreTime, 1.0)) -- Debug
  52. buffer = buffer + script.updateDt()
  53.  
  54. local sciPosition = findSci()
  55. if sciPosition then
  56. -- Mine is on this world, put buffer onto the exploration timer
  57. storage.exploreTimer = storage.exploreTimer + buffer
  58. buffer = 0
  59. if world.magnitude(mcontroller.position(), sciPosition) < self.findRange then
  60. self.state:set(mineFound)
  61. coroutine.yield()
  62. end
  63. elseif sciPosition == nil then
  64. -- Gate is not in this world, discard the buffer
  65. buffer = 0
  66. end
  67. coroutine.yield()
  68. end
  69.  
  70. storage.stage = 2
  71.  
  72. player.radioMessage("gaterepair-findGate")
  73.  
  74. util.wait(8)
  75.  
  76. self.state:set(self.stages[storage.stage])
  77. end
  78.  
  79. function findSci()
  80. quest.setProgress(nil)
  81. quest.setObjectiveList({{self.descriptions.findScientist, false}})
  82.  
  83. -- Wait until the player is no longer on the ship
  84. local findMine = util.uniqueEntityTracker(self.scientistUid, self.compassUpdate)
  85. while true do
  86. local result = findSci()
  87. questutil.pointCompassAt(result)
  88. if result and world.magnitude(mcontroller.position(), result) < self.findRange then
  89. self.state:set(sciFound)
  90. end
  91. coroutine.yield()
  92. end
  93.  
  94. self.state:set(self.stages[storage.stage])
  95. end
  96.  
  97. function sciFound()
  98. quest.setProgress(nil)
  99. quest.setCompassDirection(nil)
  100. player.radioMessage("gaterepair-gateFound1")
  101. player.radioMessage("gaterepair-gateFound1b")
  102. player.radioMessage("gaterepair-gateFound2")
  103. quest.setCanTurnIn(true)
  104. end
  105.  
  106. -- function collectRepairItem()
  107. -- quest.setCompassDirection(nil)
  108. --
  109. -- while storage.stage == 2 do
  110. -- quest.setObjectiveList({{self.descriptions.collectRepairItem, false}})
  111. -- quest.setProgress(player.hasCountOfItem(self.gateRepairItem) / self.gateRepairCount)
  112. -- if player.hasItem({name = self.gateRepairItem, count = self.gateRepairCount}) then
  113. -- storage.stage = 3
  114. -- end
  115. -- coroutine.yield()
  116. -- end
  117. --
  118. -- quest.setObjectiveList({})
  119. --
  120. -- self.state:set(self.stages[storage.stage])
  121. -- end
  122. --
  123. -- function getBackShip()
  124. -- quest.setCompassDirection(nil)
  125. -- quest.setObjectiveList({{self.descriptions.getBackShip, false}})
  126. --
  127. -- if not storage.bookmarked then
  128. -- player.addTeleportBookmark(config.getParameter("outpostBookmark"))
  129. -- storage.bookmarked = true
  130. -- end
  131. --
  132. -- while not storage.complete do
  133. -- if player.worldId() == player.ownShipWorldId() then
  134. -- storage.complete = true
  135. -- end
  136. -- coroutine.yield()
  137. -- end
  138. -- self.state:set(self.stages[storage.stage])
  139. -- end
  140.  
  141. -- function repairGate()
  142. -- quest.setCompassDirection(nil)
  143. -- quest.setProgress(nil)
  144. --
  145. -- quest.setParameter("ancientgate", {type = "entity", uniqueId = self.gateUid})
  146. -- quest.setIndicators({"ancientgate"})
  147. --
  148. -- quest.setObjectiveList({
  149. -- {self.descriptions.repairGate, false}
  150. -- })
  151. --
  152. -- local findGate = util.uniqueEntityTracker(self.gateUid, self.compassUpdate)
  153. -- while storage.stage == 4 do
  154. -- questutil.pointCompassAt(findGate())
  155. --
  156. -- -- Go back to last stage if player loses core fragments
  157. -- if not player.hasItem({name = self.gateRepairItem, count = self.gateRepairCount}) then
  158. -- storage.stage = 3
  159. -- self.state:set(self.stages[storage.stage])
  160. -- end
  161. --
  162. -- coroutine.yield()
  163. -- end
  164. --
  165. -- self.onInteract = nil
  166. -- self.state:set(self.stages[storage.stage])
  167. -- end
  168. --
  169. -- function gateRepaired()
  170. -- self.onInteract = nil
  171. -- quest.setCompassDirection(nil)
  172. -- quest.setProgress(nil)
  173. -- quest.setIndicators({})
  174. --
  175. -- storage.stage = 5
  176. --
  177. -- player.radioMessage("gaterepair-gateOpened1")
  178. -- player.radioMessage("gaterepair-gateOpened2")
  179. --
  180. -- self.state:set(self.stages[storage.stage])
  181. -- end
  182. --
  183. -- function findEsther(dt)
  184. -- quest.setCompassDirection(nil)
  185. -- quest.setParameter("esther", {type = "entity", uniqueId = self.estherUid})
  186. -- quest.setIndicators({"esther"})
  187. -- quest.setObjectiveList({{self.descriptions.findEsther, false}})
  188. --
  189. -- local trackEsther = util.uniqueEntityTracker(self.estherUid, self.compassUpdate)
  190. -- local trackGate = util.uniqueEntityTracker(self.gateUid, self.compassUpdate)
  191. -- while true do
  192. -- if not storage.complete then
  193. -- local estherResult = trackEsther()
  194. -- questutil.pointCompassAt(estherResult)
  195. -- if estherResult then
  196. -- if not storage.bookmarked then
  197. -- player.addTeleportBookmark(config.getParameter("outpostBookmark"))
  198. -- storage.bookmarked = true
  199. -- end
  200. -- if world.magnitude(estherResult, mcontroller.position()) < self.findRange then
  201. -- player.playCinematic(config.getParameter("findEstherCinema"))
  202. -- storage.complete = true
  203. -- end
  204. -- end
  205. -- else
  206. -- quest.setCanTurnIn(true)
  207. -- quest.setIndicators({})
  208. -- end
  209. -- coroutine.yield()
  210. -- end
  211. -- self.state:set(self.stages[storage.stage])
  212. -- end
  213.  
  214. function questComplete()
  215. setPortraits()
  216. questutil.questCompleteActions()
  217. end
  218.  
Success #stdin #stdout 0s 14112KB
stdin
Standard input is empty
stdout
Standard output is empty