BDG_Daxx

Bug Somewhere Q_Q

Aug 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 KB | None | 0 0
  1. Scriptname MeadControlLeverScript extends ObjectReference
  2.  
  3. import debug
  4. import utility
  5.  
  6.  
  7. Bool Property ReadyToPour Auto
  8.  
  9. ObjectReference Property Waterfall Auto ; Waterfall
  10.  
  11. ObjectReference Property WaterAudio Auto ; Waterfall Audio
  12.  
  13. ObjectReference Property WaterLevel Auto ; Mead Water in cask
  14.  
  15. ObjectReference Property FullCask Auto ; Full cask (default disabled)
  16.  
  17. ObjectReference Property EmptyDefaultCask Auto ; empty cask object (to hide and replace with full cask)
  18.  
  19. Float Property Delay Auto
  20.  
  21. Message Property StoreWarehouseMessage Auto
  22.  
  23. ObjectReference[] Property WarehouseBarrels Auto
  24.  
  25. Bool property isInPullPosition = True Auto
  26.  
  27. DXXAMMeadBoilerScript[] Property BoilerScripts Auto
  28.  
  29. ObjectReference[] Property OverheadPipes Auto
  30.  
  31. MeadControlButton Property ControlButtonScript Auto
  32.  
  33. ObjectReference Property WarehouseEnabled Auto
  34.  
  35. DXXAMMeadWarehouseBarrelScript[] Property WarehouseBarrelScripts Auto
  36.  
  37. EVENT OnLoad()
  38. SetDefaultState()
  39. endEVENT
  40.  
  41. Event OnReset()
  42. SetDefaultState()
  43. EndEvent
  44.  
  45. ;This has to be handled as a function, since OnLoad and OnReset can fire in either order, and we can't handle competing animation calls.
  46. Function SetDefaultState()
  47. if (isInPullPosition)
  48. playAnimation("FullPull")
  49. gotoState("pulledPosition")
  50. Else
  51. playAnimation("FullPush")
  52. gotoState("pushedPosition")
  53. EndIf
  54. EndFunction
  55.  
  56. Function PackageBarrel()
  57. Waterfall.Enable(true)
  58. WaterAudio.Enable()
  59. Wait(Delay)
  60. WaterLevel.Enable(true)
  61.  
  62. Bool Filling = true
  63. While Filling
  64. Filling = FillUp()
  65. EndWhile
  66. Waterfall.Disable(true)
  67. WaterAudio.Disable()
  68. Wait(1)
  69. ;At this point, we have a full cask of mead (open), and have stopped the pouring
  70.  
  71. EmptyDefaultCask.Disable()
  72. FullCask.Enable(true)
  73. WaterLevel.SetPosition(WaterLevel.GetPositionX(),WaterLevel.GetPositionY(),100)
  74. WaterLevel.Disable(true)
  75. ;At this point, we have only the full cask of mead (closed), everything else disabled
  76.  
  77.  
  78. ;Make our call to find open barrels here, then figure out how to display ONLY the valid locations
  79. Bool keepLooking = true
  80. Int Choice = 0
  81. while KeepLooking
  82. Choice = StoreWarehouseMessage.Show(1,2,3,4,5,6,7,8,9)
  83. if WarehouseBarrelScripts[Choice].CanBeFilled()
  84. ;Debug.Notification("FUCK YES")
  85. KeepLooking = false
  86. else
  87. Debug.Notification("Please pick a barrel that exists and is empty")
  88. endIf
  89. endWhile
  90.  
  91. int PumpedBoiler = ControlButtonScript.GetActiveBoiler()
  92. Debug.Notification("Boiler #" + PumpedBoiler + " Emptied.")
  93. Debug.Notification("Cask of " + BoilerScripts[PumpedBoiler].GetType() + " mead sent to Warehouse spot " + Choice)
  94.  
  95. ;AT THIS POINT, WE WANT TO ENABLE TO WAREHOUSE BARREL WITH THE CORRECT MEAD INSIDE
  96. WarehouseBarrelScripts[Choice].FillWithMead(Choice)
  97.  
  98. FullCask.Disable(true) ; disable the full cask
  99. wait(2)
  100. EmptyDefaultCask.Enable(true) ; enable the empty cask, return to default state.
  101. EndFunction
  102.  
  103. Bool[] Function FindOpenBarrelLocations()
  104. Bool[] BarrelLocations = new Bool[9]
  105. Int i = BarrelLocations.Length
  106. While i
  107. i -= 1
  108. if WarehouseBarrels[i].IsEnabled()
  109. BarrelLocations[i] = true
  110. endIf
  111. EndWhile
  112. return BarrelLocations
  113. EndFunction
  114.  
  115. Bool Function FillUp()
  116. if WaterLevel.GetPositionZ() <= 180
  117. WaterLevel.SetPosition(WaterLevel.GetPositionX(),WaterLevel.GetPositionY(),WaterLevel.GetPositionZ() + 1.5)
  118. Wait(0.5)
  119. return true
  120. endIf
  121. return false
  122. EndFunction
  123.  
  124. Bool Function IsOneValidBarrel()
  125. int Holder = 0
  126. ; FOR LOOP HERE FOR EACH INDEX IN BARRELS ARRAY - CHECK FOR ACTIVE AND CHECK FOR EMPTY - I THINK I MADE A HELPER FUNCTION FOR IT ALREADY
  127. Int Idr = WarehouseBarrelScripts.Length
  128. while Idr > 1 ; --------- DEBUG ---------- THIS WAS 0, MIGHT BE CAUSING CRASH - Checking IsDisabled() ON A NONE OBJECT REFERENCE
  129. Idr -= 1
  130. if WarehouseBarrelScripts[Idr].CanBeFilled()
  131. Holder+= 1
  132. endIf
  133. endWhile
  134. if Holder > 0
  135. return true
  136. endIf
  137. return false
  138. EndFunction
  139.  
  140. Auto STATE pulledPosition
  141. EVENT onActivate (objectReference triggerRef)
  142. gotoState ("busy")
  143. isInPullPosition = False
  144. playAnimationandWait("FullPush","FullPushedUp")
  145. int ActiveBoiler = ControlButtonScript.GetActiveBoiler()
  146. ;Package a barrel
  147. if ReadyToPour
  148. if (ActiveBoiler == 3 || ActiveBoiler == 2 || ActiveBoiler == 1) && OverheadPipes[1].IsDisabled()
  149. Debug.Notification("You cannot pump this row until you connect it to the pipe network")
  150. elseif(ActiveBoiler == 4 || ActiveBoiler == 5 || ActiveBoiler == 6) && OverheadPipes[2].IsDisabled()
  151. Debug.Notification("You cannot pump this row until you connect it to the pipe network")
  152. elseif(ActiveBoiler == 4 || ActiveBoiler == 5 || ActiveBoiler == 6) && OverheadPipes[2].IsDisabled()
  153. Debug.Notification("You cannot pump this row until you connect it to the pipe network")
  154. elseif BoilerScripts[ActiveBoiler].IsBoilerBrewing()
  155. Debug.Notification("You cannot pack incomplete mead")
  156. elseif WarehouseEnabled.IsDisabled()
  157. Debug.Notification("You must build a warehouse to store your product first")
  158. elseif BoilerScripts[ActiveBoiler].IsFinishedBrewing()
  159. If IsOneValidBarrel()
  160. PackageBarrel()
  161. BoilerScripts[ActiveBoiler].PumpMeadToFillingStation()
  162. endIf
  163. else
  164. Debug.Notification("There is no mead in this Boiler to pump")
  165. endIf
  166. endIf
  167. gotoState("pushedPosition")
  168. Wait(1)
  169. Activate(Game.GetPlayer())
  170. endEVENT
  171. endState
  172.  
  173. STATE pushedPosition
  174. EVENT onActivate (objectReference triggerRef)
  175. gotoState ("busy")
  176. isInPullPosition = True
  177. playAnimationandWait("FullPull","FullPulledDown")
  178. gotoState("pulledPosition")
  179. endEVENT
  180. endState
  181.  
  182. STATE busy
  183. ; This is the state when I'm busy animating
  184. EVENT onActivate (objectReference triggerRef)
  185. ;do nothing
  186. endEVENT
  187. endSTATE
Advertisement
Add Comment
Please, Sign In to add comment