Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.64 KB | None | 0 0
  1.  
  2. function onload()
  3. SetUpPlanetObjects()
  4. timeCount = 0
  5. newTime = os.clock()
  6. oldTime = 0
  7.  
  8.  
  9.  
  10. PassedPlayerName = "default"
  11. RemoteClaim = 0
  12.  
  13. self.createButton({
  14. label="Ready Planets", click_function='ReadyPlanets', function_owner=self,
  15. position={6.7,0.3,0}, height=250, width=3000, font_size=200, alignment=2,
  16. rotation={0,-90,0},
  17. font_color = {1,1,1},
  18. color = {0.05, 0.05, 0.05}
  19. })
  20. self.createButton({
  21. label="TotalInfluence", click_function='TotalInfluence', function_owner=self,
  22. position={-7,0.3,-2.5}, height=500, width=800, font_size=350, alignment=2,
  23. rotation={0,-90,0},
  24. font_color = {0.2,0.2,1},
  25. color = {0.05, 0.05, 0.05}
  26. })
  27. self.createButton({
  28. label="Status Phase: 6) Ready Planets and at end of Agenda Phase", click_function='Nada', function_owner=self,
  29. position={6.2,0.3,0}, height=200, width=3000, font_size=80, alignment=2,
  30. rotation={0,-90,0},
  31. font_color = {1,1,1},
  32. color = {0.05, 0.05, 0.05}
  33. })
  34. self.createButton({
  35. label="TotalResources", click_function='TotalResources', function_owner=self,
  36. position={-7,0.3,2.5}, height=500, width=800, font_size=350, alignment=2,
  37. rotation={0,-90,0},
  38. font_color = {0.8,0.7,0.2},
  39. color = {0.05, 0.05, 0.05}
  40. })
  41. self.createButton({
  42. label="TotalNonhome", click_function='TotalNonhome', function_owner=self,
  43. position={-7,0.3,0}, height=500, width=800, font_size=350, alignment=2,
  44. rotation={0,-90,0},
  45. font_color = {0.9,0.9,0.9},
  46. color = {0.05, 0.05, 0.05}
  47. })
  48. end
  49.  
  50. function Nada()
  51. end
  52.  
  53. function ReadyPlanets()
  54. self.editButton{index = 0, label = "Confirm", click_function = 'ActuallyReadyPlanets'}
  55. Wait.time(function() ResetReadyPlanets() end, 2)
  56. end
  57.  
  58. function ActuallyReadyPlanets(j, c, a)
  59. FlippingPlayer = Player[c].steam_name
  60. PlayerColorRGB = stringColorToRGB(c)
  61. PlayerColorHex = HexColor(c)
  62. broadcastToAll ("["..PlayerColorHex.."]"..FlippingPlayer.."[ffffff] readied planets.")
  63. FlipCardsFaceUp()
  64. ResetReadyPlanets()
  65. end
  66.  
  67. function ResetReadyPlanets()
  68. self.editButton{index = 0, label = "Ready Planets", click_function = 'ReadyPlanets'}
  69. end
  70.  
  71. function HexColor(colorString)
  72. local colorTable = stringColorToRGB(colorString)
  73. colorTable = {colorTable[1]*255,colorTable[2]*255,colorTable[3]*255}
  74. local colorHex = string.format('%02x%02x%02x', unpack(colorTable))
  75. return colorHex
  76. end
  77.  
  78. function update()
  79. calculateDelta()
  80. oldTimeCount = timeCount
  81. timeCount = timeCount + 1 * deltaTime
  82. if getTimeString(oldTimeCount) ~= getTimeString(timeCount) then
  83. persecond()
  84. else
  85. end
  86. end
  87. --=========================
  88. --=========================
  89. --=========================
  90. function persecond()
  91. TotalValue("Influence", 1)
  92. TotalValue("Resources", 3)
  93. TotalValueNoExhaust("Nonhome", 4)
  94. end
  95. --=========================
  96. --=========================
  97. --=========================
  98. function IsCardExhausted(j)
  99. local CardRotation = j.getRotation()[3]
  100. if math.abs(CardRotation - 180) < 5 then
  101. return true
  102. else
  103. return false
  104. end
  105. end
  106.  
  107. function ReturnValue(planetname, value)
  108. if PlanetObjects[planetname] ~= nil then
  109. return PlanetObjects[planetname][value]
  110. else
  111. return 0
  112. end
  113. end
  114.  
  115. function TotalValue(value, bindex)
  116. --print("New TotalInfluence")
  117. local NearbyObjects = FindInBox()
  118. local val = 0
  119. for i, j in pairs (NearbyObjects) do
  120. if IsCardExhausted(j.hit_object) == false then
  121. local returnedval = ReturnValue(j.hit_object.getName(), value)
  122. val = val + returnedval
  123. end
  124. end
  125. self.editButton({index = bindex, label = val})
  126. end
  127.  
  128. function TotalValueNoExhaust(value, bindex)
  129. --print("New TotalInfluence")
  130. local NearbyObjects = FindInBox()
  131. local val = 0
  132. for i, j in pairs (NearbyObjects) do
  133. local returnedval = ReturnValue(j.hit_object.getName(), value)
  134. val = val + returnedval
  135. end
  136. self.editButton({index = bindex, label = val})
  137. end
  138.  
  139. function FindInBox()
  140. local S = 20
  141. local CastVectorOrigin =
  142. {
  143. self.getPosition()[1],
  144. self.getPosition()[2] + 1,
  145. self.getPosition()[3]
  146. }
  147.  
  148. return Physics.cast({
  149. origin=CastVectorOrigin,
  150. type=3,
  151. size={S-8,5,S+1},
  152. direction = {0,0.1,0},
  153. max_distance = 1,
  154. debug = false
  155. })
  156. end
  157.  
  158.  
  159.  
  160. function FlipCardsFaceUp()
  161. local NearbyObjects = FindInBox()
  162. for i, j in pairs (NearbyObjects) do
  163. --filter out the table, self and boards
  164. if j.hit_object ~= self
  165. and tostring(j.hit_object.getGUID()) ~= "nil"
  166. and j.hit_object.getName() ~= ""
  167. and j.hit_object.getName() ~= "Board"
  168. and j.hit_object.getName() ~= "BigBoard"
  169. then
  170. j.hit_object.setRotationSmooth({0,self.getRotation()[2]-90,0}, false, false)
  171. end
  172. end
  173. end
  174.  
  175. function getTimeString(x)
  176. local timeInSeconds = math.ceil(x)
  177. local minutes = math.floor(timeInSeconds/60)
  178. local seconds = timeInSeconds % 60
  179. return string.format("%d:%02d",minutes,seconds)
  180. end
  181.  
  182. function calculateDelta()
  183.  
  184. oldTime = newTime
  185. newTime = os.clock()
  186. deltaTime = newTime - oldTime
  187.  
  188. end
  189.  
  190.  
  191. function SetUpPlanetObjects()
  192. PlanetObjects = {}
  193. PlanetObjects["Abyz"]={Type="Hazardous",Resources=3,Influence=0,Nonhome=1}
  194. PlanetObjects["Arinam"]={Type="Industrial",Resources=1,Influence=2,Nonhome=1}
  195. PlanetObjects["Arnor"]={Type="Industrial",Resources=2,Influence=1,Nonhome=1}
  196. PlanetObjects["Bereg"]={Type="Hazardous",Resources=3,Influence=1,Nonhome=1}
  197. PlanetObjects["Centauri"]={Type="Cultural",Resources=1,Influence=3,Nonhome=1}
  198. PlanetObjects["Corneeq"]={Type="Cultural",Resources=1,Influence=2,Nonhome=1}
  199. PlanetObjects["Dal Bootha"]={Type="Cultural",Resources=0,Influence=2,Nonhome=1}
  200. PlanetObjects["Fria"]={Type="Hazardous",Resources=2,Influence=0,Nonhome=1}
  201. PlanetObjects["Gral"]={Type="Industrial",Resources=1,Influence=1,Nonhome=1}
  202. PlanetObjects["Lazar"]={Type="Industrial",Resources=1,Influence=0,Nonhome=1}
  203. PlanetObjects["Lirta IV"]={Type="Hazardous",Resources=2,Influence=3,Nonhome=1}
  204. PlanetObjects["Lodor"]={Type="Cultural",Resources=3,Influence=1,Nonhome=1}
  205. PlanetObjects["Lor"]={Type="Industrial",Resources=1,Influence=2,Nonhome=1}
  206. PlanetObjects["Mecatol Rex"]={Type="Mecatol",Resources=1,Influence=6,Nonhome=1}
  207. PlanetObjects["Meer"]={Type="Hazardous",Resources=0,Influence=4,Nonhome=1}
  208. PlanetObjects["Mehar Xull"]={Type="Hazardous",Resources=1,Influence=3,Nonhome=1}
  209. PlanetObjects["Mellon"]={Type="Cultural",Resources=0,Influence=2,Nonhome=1}
  210. PlanetObjects["New Albion"]={Type="Industrial",Resources=1,Influence=1,Nonhome=1}
  211. PlanetObjects["Quann"]={Type="Cultural",Resources=2,Influence=1,Nonhome=1}
  212. PlanetObjects["Qucen'n"]={Type="Industrial",Resources=1,Influence=2,Nonhome=1}
  213. PlanetObjects["Rarron"]={Type="Cultural",Resources=0,Influence=3,Nonhome=1}
  214. PlanetObjects["Resculon"]={Type="Cultural",Resources=2,Influence=0,Nonhome=1}
  215. PlanetObjects["Sakulag"]={Type="Hazardous",Resources=2,Influence=1,Nonhome=1}
  216. PlanetObjects["Saudor"]={Type="Industrial",Resources=2,Influence=2,Nonhome=1}
  217. PlanetObjects["Starpoint"]={Type="Hazardous",Resources=3,Influence=1,Nonhome=1}
  218. PlanetObjects["Tar'Mann"]={Type="Industrial",Resources=1,Influence=1,Nonhome=1}
  219. PlanetObjects["Tequ'Ran"]={Type="Hazardous",Resources=2,Influence=0,Nonhome=1}
  220. PlanetObjects["Thibah"]={Type="Industrial",Resources=1,Influence=1,Nonhome=1}
  221. PlanetObjects["Torkan"]={Type="Cultural",Resources=0,Influence=3,Nonhome=1}
  222. PlanetObjects["Vefut II"]={Type="Hazardous",Resources=2,Influence=2,Nonhome=1}
  223. PlanetObjects["Wellon"]={Type="Industrial",Resources=1,Influence=2,Nonhome=1}
  224. PlanetObjects["XXehan"]={Type="Cultural",Resources=1,Influence=1,Nonhome=1}
  225. PlanetObjects["Zohbat"]={Type="Hazardous",Resources=3,Influence=1,Nonhome=1}
  226. PlanetObjects["Nestphar"]={Type="Arborec",Resources=3,Influence=2,Nonhome=0}
  227. PlanetObjects["Creuss"]={Type="Creuss",Resources=4,Influence=2,Nonhome=0}
  228. PlanetObjects["Arretze"]={Type="Hacan",Resources=2,Influence=0,Nonhome=0}
  229. PlanetObjects["Hercant"]={Type="Hacan",Resources=1,Influence=1,Nonhome=0}
  230. PlanetObjects["Kamdorn"]={Type="Hacan",Resources=0,Influence=1,Nonhome=0}
  231. PlanetObjects["Jol"]={Type="Jol-Nar",Resources=1,Influence=2,Nonhome=0}
  232. PlanetObjects["Nar"]={Type="Jol-Nar",Resources=2,Influence=3,Nonhome=0}
  233. PlanetObjects["[0.0.0]"]={Type="L1Z1X",Resources=5,Influence=0,Nonhome=0}
  234. PlanetObjects["Arc Prime"]={Type="Letnev",Resources=4,Influence=0,Nonhome=0}
  235. PlanetObjects["Wren Terra"]={Type="Letnev",Resources=2,Influence=1,Nonhome=0}
  236. PlanetObjects["Moll Primus"]={Type="Mentak",Resources=4,Influence=1,Nonhome=0}
  237. PlanetObjects["Muaat"]={Type="Muaat",Resources=4,Influence=1,Nonhome=0}
  238. PlanetObjects["Druaa"]={Type="Naalu",Resources=3,Influence=1,Nonhome=0}
  239. PlanetObjects["Maaluuk"]={Type="Naalu",Resources=0,Influence=2,Nonhome=0}
  240. PlanetObjects["Mordai II"]={Type="Nekro Virus",Resources=4,Influence=0,Nonhome=0}
  241. PlanetObjects["Lisis II"]={Type="Saar",Resources=1,Influence=0,Nonhome=0}
  242. PlanetObjects["Ragh"]={Type="Saar",Resources=2,Influence=1,Nonhome=0}
  243. PlanetObjects["Quinarra"]={Type="Sardakk N'orr",Resources=3,Influence=1,Nonhome=0}
  244. PlanetObjects["Tren'Lak"]={Type="Sardakk N'orr",Resources=1,Influence=0,Nonhome=0}
  245. PlanetObjects["Jord"]={Type="Sol",Resources=4,Influence=2,Nonhome=0}
  246. PlanetObjects["Winnu"]={Type="Winnu",Resources=3,Influence=4,Nonhome=0}
  247. PlanetObjects["Archon Ren"]={Type="Xxcha",Resources=2,Influence=3,Nonhome=0}
  248. PlanetObjects["Archon Tau"]={Type="Xxcha",Resources=1,Influence=1,Nonhome=0}
  249. PlanetObjects["Darien"]={Type="Yin",Resources=4,Influence=4,Nonhome=0}
  250. PlanetObjects["Retillion"]={Type="Yssaril",Resources=2,Influence=3,Nonhome=0}
  251. PlanetObjects["Shalloq"]={Type="Yssaril",Resources=1,Influence=2,Nonhome=0}
  252. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement