Advertisement
ddson888

Untitled

Mar 10th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.10 KB | None | 0 0
  1. function onSave()
  2. local data_to_save = {
  3.  
  4. ["SarweenToolsState"]=SarweenTools,
  5. ["MuaatWarSunState"]=MuaatWarSun,
  6. ["RegulatedConscriptionState"]=RegulatedConscription
  7.  
  8. }
  9.  
  10. saved_data = JSON.encode(data_to_save)
  11. --print(tostring(saved_data).." is saved data.")
  12. return saved_data
  13. end
  14.  
  15.  
  16. function onload(saved_data)
  17.  
  18. --print(tostring(saved_data).." is saved data.")
  19.  
  20.  
  21. if string.find(self.getName(), "1") then
  22. CountingArea = getObjectFromGUID('7666f1')
  23. ShipBag = getObjectFromGUID('b5edda')
  24. end
  25.  
  26. if string.find(self.getName(), "2") then
  27. CountingArea = getObjectFromGUID('1282f2')
  28. ShipBag = getObjectFromGUID('57f5ec')
  29. end
  30.  
  31. if string.find(self.getName(), "3") then
  32. CountingArea = getObjectFromGUID('669da8')
  33. ShipBag = getObjectFromGUID('62980e')
  34. end
  35.  
  36. if string.find(self.getName(), "4") then
  37. CountingArea = getObjectFromGUID('a8965e')
  38. ShipBag = getObjectFromGUID('b26a33')
  39. end
  40.  
  41. if string.find(self.getName(), "5") then
  42. CountingArea = getObjectFromGUID('c9944a')
  43. ShipBag = getObjectFromGUID('38beb1')
  44. end
  45.  
  46. if string.find(self.getName(), "6") then
  47. CountingArea = getObjectFromGUID('750ef2')
  48. ShipBag = getObjectFromGUID('b306be')
  49. end
  50.  
  51. --ShipBag.interactable = false
  52. ColorButtonsExist = 0
  53.  
  54.  
  55. -----------------------
  56. ShipTable = {}
  57. BloccTable = {}
  58. CreateShipObjects()
  59.  
  60. SpawnShipCubes()
  61. Timer.create({identifier = "LockBloccs"..self.getGUID(), function_name = 'LoccBloccs', delay = 1.3})
  62.  
  63. SarweenTools = false
  64. RegulatedConscription = false
  65. MuaatWarSun = false
  66.  
  67. PassedColor = nil
  68. ColorSwitch = false
  69.  
  70. ButtonHeight = 0.6
  71. EvaluateSwitch = false
  72.  
  73. self.createButton({
  74. label=ShipCost, click_function='Nada', function_owner=self,
  75. position={-10,ButtonHeight,-1.455}, height=500, width=1300, font_size=400, alignment=2
  76. })
  77. self.createButton({
  78. label="Resource Cost", click_function='Nada', function_owner=self,
  79. position={-13.5,ButtonHeight,-1.455}, height=500, width=2200, font_size=300, alignment=2
  80. })
  81. self.createButton({
  82. label="ProdNum", click_function='Nada', function_owner=self,
  83. position={-10,ButtonHeight,-0.255}, height=500, width=1300, font_size=400, alignment=2
  84. })
  85. self.createButton({
  86. label="Production", click_function='Nada', function_owner=self,
  87. position={-13.5,ButtonHeight,-0.255}, height=500, width=2200, font_size=300, alignment=2
  88. })
  89. self.createButton({
  90. label="Sarween Off", click_function='ToggleSarween', function_owner=self,
  91. position={-13,ButtonHeight+0.1,0.4}, height=200, width=600, font_size=100, alignment=2
  92. })
  93. self.createButton({
  94. label="Regulated Conscription Off", click_function='ToggleRegulatedConscription', function_owner=self,
  95. position={-13,ButtonHeight+0.1,0.8}, height=200, width=600, font_size=40, alignment=2
  96. })
  97. self.createButton({
  98. label="Muaat Upgraded War Sun Off", click_function='ToggleMuaatWarSun', function_owner=self,
  99. position={-13,ButtonHeight+0.1,1.2}, height=200, width=600, font_size=40, alignment=2
  100. })
  101. self.createButton({
  102. label="Recolour", click_function='SpawnColorButtons', function_owner=self,
  103. position={-15,ButtonHeight+0.1,0.4}, height=200, width=600, font_size=100, alignment=2
  104. })
  105.  
  106. SortSelfOut()
  107. Timer.create({identifier = "EvalShips"..self.getGUID(), function_name = 'EvaluateShips', delay = 0.1})
  108.  
  109.  
  110. if saved_data ~= nil and saved_data ~= "" then
  111.  
  112. loaded_data = JSON.decode(saved_data)
  113. --print(tostring(loaded_data.MuaatWarSunState).." is MuaatWarSunState.")
  114. if loaded_data.MuaatWarSunState then
  115. ToggleMuaatWarSun()
  116. end
  117.  
  118. if loaded_data.RegulatedConscriptionState then
  119. ToggleRegulatedConscription()
  120. end
  121.  
  122. if loaded_data.SarweenToolsState then
  123. ToggleSarween()
  124. end
  125.  
  126. end
  127.  
  128.  
  129. end
  130.  
  131.  
  132. function onDestroy()
  133. for i,j in pairs(BloccTable) do
  134. destroyObject(j)
  135. end
  136. local DestroyThese = CountingArea.getObjects()
  137. for i,j in pairs(DestroyThese ) do
  138. destroyObject(j)
  139. end
  140. end
  141.  
  142.  
  143. function ToggleMuaatWarSun()
  144. MuaatWarSun = not MuaatWarSun
  145. if MuaatWarSun == true then
  146. self.editButton({index = 6, label = "Muaat Upgraded War Sun On", color = {0.2,0.8,0.2}})
  147. warsun.Cost = 10
  148. else
  149. self.editButton({index = 6, label = "Muaat Upgraded War Sun Off", color = {0.05, 0.05, 0.05}})
  150. warsun.Cost = 12
  151. end
  152. EvaluateShips()
  153. end
  154.  
  155. function update()
  156. if EvaluateSwitch == true then
  157. EvaluateShips()
  158. EvaluateSwitch = false
  159. --print ("Evaluated ships from switch.")
  160. end
  161. if ColorSwitch == true then
  162. ChangeMyColor(PassedColor)
  163. ColorSwitch = false
  164. end
  165. end
  166.  
  167.  
  168. function ToggleRegulatedConscription()
  169. RegulatedConscription = not RegulatedConscription
  170. if RegulatedConscription == true then
  171. self.editButton({index = 5, label = "Regulated Conscription On", color = {0.2,0.8,0.2}})
  172. fighter.Cost = 1
  173. infantry.Cost = 1
  174. else
  175. self.editButton({index = 5, label = "Regulated Conscription Off", color = {0.2,0.8,0.2}})
  176. fighter.Cost = 0.5
  177. infantry.Cost = 0.5
  178. end
  179. EvaluateShips()
  180. end
  181.  
  182.  
  183. function ToggleRegulatedConscription()
  184. RegulatedConscription = not RegulatedConscription
  185. if RegulatedConscription == true then
  186. self.editButton({index = 5, label = "Regulated Conscription On", color = {0.2,0.8,0.2}})
  187. fighter.Cost = 1
  188. infantry.Cost = 1
  189. else
  190. self.editButton({index = 5, label = "Regulated Conscription Off", color = {0.05, 0.05, 0.05}})
  191. fighter.Cost = 0.5
  192. infantry.Cost = 0.5
  193. end
  194. EvaluateShips()
  195. end
  196.  
  197.  
  198.  
  199. function ToggleSarween()
  200. SarweenTools = not SarweenTools
  201. if SarweenTools == true then
  202. self.editButton({index = 4, label = "Sarween On", color = {0.2,0.8,0.2}})
  203. else
  204. self.editButton({index = 4, label = "Sarween Off", color = {0.05, 0.05, 0.05}})
  205. end
  206. EvaluateShips()
  207. end
  208.  
  209. function SortSelfOut()
  210.  
  211. for i=0,7,1 do
  212. self.editButton({index = i, font_color = ShipBag.getColorTint(), color = {0.05, 0.05, 0.05}})
  213. end
  214. -- self.removeButton(5)
  215. -- self.removeButton(6)
  216. self.setColorTint({0,0,0})
  217. end
  218.  
  219. function SetBloccColor(blocc)
  220. blocc.editButton({index = 0, font_color = ShipBag.getColorTint()})
  221. blocc.editButton({index = 1, font_color = ShipBag.getColorTint()})
  222. blocc.editButton({index = 2, font_color = ShipBag.getColorTint()})
  223. blocc.editButton({index = 3, font_color = ShipBag.getColorTint()})
  224. blocc.setColorTint({0,0,0})
  225. end
  226.  
  227. function EvaluateShips(extra)
  228. local TC = 0
  229. if SarweenTools == true then
  230. TC = -1
  231. end
  232.  
  233.  
  234. local TotalShips = 0
  235. local ShipsToEvaluate = FindShipsInCountingArea()
  236. --print("ShipsToEvaluate is length "..#ShipsToEvaluate)
  237. if extra ~= nil then
  238. table.insert(ShipsToEvaluate, extra)
  239. end
  240.  
  241. for i, j in pairs(ShipsToEvaluate) do
  242. if IdentifyShip(j) ~= nil then
  243. --print(IdentifyShip(j).Name.." is what IdentifyShip returned.")
  244. TC = TC + IdentifyShip(j).Cost
  245. TotalShips = TotalShips + 1
  246. end
  247. end
  248.  
  249. self.editButton({index = 0, label = tostring(TC)})
  250. self.editButton({index = 2, label = tostring(TotalShips)})
  251.  
  252. end
  253.  
  254. function onObjectDestroyed(obj)
  255. --print("Object destroyed, evaluating...")
  256. if HasShipName(obj) then
  257. --print("HasShipName true.")
  258. if HasMyShipbagColorTint(obj) then
  259. --print("HasMyShipbagColorTint true.")
  260. Timer.create({identifier = tostring(math.random(1,9999999)..self.getGUID()), function_name = 'EvaluateShips', delay = 0.1})
  261. end
  262. end
  263. end
  264.  
  265. function HasShipName(j)
  266. if
  267. string.find(j.getName(), "Destroyer") or
  268. string.find(j.getName(), "Cruiser") or
  269. string.find(j.getName(), "Dreadnought") or
  270. string.find(j.getName(), "Carrier") or
  271. string.find(j.getName(), "Fighter") or
  272. string.find(j.getName(), "Infantry") or
  273. string.find(j.getName(), "Flagship") or
  274. string.find(j.getName(), "War Sun")
  275. then return true
  276. else
  277. return false
  278. end
  279. end
  280.  
  281. function HasMyShipbagColorTint(obj)
  282. --print(obj.getColorTint()[1])
  283. --print(ShipBag.getColorTint()[1])
  284. --print(obj.getColorTint()[2])
  285. --print(ShipBag.getColorTint()[2])
  286.  
  287.  
  288. if
  289.  
  290. math.floor(obj.getColorTint()[1]*100) == math.floor(ShipBag.getColorTint()[1]*100) and
  291. math.floor(obj.getColorTint()[2]*100) == math.floor(ShipBag.getColorTint()[2]*100) and
  292. math.floor(obj.getColorTint()[3]*100) == math.floor(ShipBag.getColorTint()[3]*100)
  293. then return true
  294. else
  295. return false
  296. end
  297. end
  298.  
  299.  
  300. --function onObjectEnterScriptingZone(zone, obj)
  301. --print("Evaluating as zone was entered.")
  302. -- if zone == CountingArea then
  303. -- EvaluateShips(obj)
  304. -- end
  305. --end
  306.  
  307. function onObjectLeaveScriptingZone(zone, obj)
  308. --print("Evaluating as zone was left.")
  309. if zone == CountingArea then
  310. EvaluateShips()
  311. end
  312.  
  313. end
  314.  
  315. function IdentifyShip(ShipTTSObject)
  316. --print("Identified "..ShipTTSObject.getName())
  317. for v = 1, 8, 1 do
  318. if string.find(ShipTTSObject.getName(), ShipTable[v].Name) then
  319. --print("Returning ShipTable[v]")
  320. return ShipTable[v]
  321. end
  322. end
  323. end
  324.  
  325.  
  326. function FindShipsInCountingArea()
  327. local ShipsInArea = {}
  328. for i, j in pairs(CountingArea.getObjects()) do
  329. if
  330. string.find(j.getName(), "Destroyer") or
  331. string.find(j.getName(), "Cruiser") or
  332. string.find(j.getName(), "Dreadnought") or
  333. string.find(j.getName(), "Carrier") or
  334. string.find(j.getName(), "Fighter") or
  335. string.find(j.getName(), "Infantry") or
  336. string.find(j.getName(), "Flagship") or
  337. string.find(j.getName(), "War Sun")
  338. then
  339. table.insert(ShipsInArea, j)
  340. end
  341. end
  342. return ShipsInArea
  343. end
  344.  
  345.  
  346. function Nada()
  347. end
  348.  
  349. function SpawnShipCubes()
  350.  
  351. BloccParams = {}
  352. BloccParams.type = 'Custom_Model'
  353. BloccParams.callback_owner = self
  354. BloccParams.mesh = 'https://pastebin.com/Q5ZH0cS2'
  355. BloccParams.diffuse = nil
  356. BloccParams.position = s
  357. BloccParams.normal = nil
  358. BloccParams.collider = 'https://pastebin.com/7iRf6cWE'
  359. BloccParams.material = 1
  360. BloccParams.scale = {0.7, 0.7, 0.7}
  361. BloccParams.sound = false
  362.  
  363.  
  364. for i, j in pairs(ShipTable) do
  365. SetSpawnPosition(i)
  366. Blocc = spawnObject(BloccParams)
  367. table.insert(BloccTable,Blocc)
  368. Blocc.setCustomObject(BloccParams)
  369. Blocc.setDescription(j.Name)
  370. Blocc.setLuaScript([[
  371.  
  372.  
  373. function Nada()
  374. end
  375.  
  376. function onload()
  377. SettedUp = false
  378. SeppukuPassed = false
  379. Timer.create({identifier = 'Seppuku:'..self.getGUID(), function_name = 'Seppuku', delay = 0.1})
  380. Timer.create({identifier = 'ShipUpdate'..self.getGUID(), function_name='UpdateShipNumber', delay = 0.2})
  381.  
  382. end
  383.  
  384. function Seppuku()
  385. if MySpawner == nil then
  386. self.Destruct()
  387. else
  388. SeppukuPassed = true
  389. end
  390. end
  391.  
  392. function onSave()
  393.  
  394. end
  395.  
  396. function update()
  397. if SpawnTrigger == true then
  398. --print("SpawnTrigger is true for me, "..self.getDescription())
  399. SetUp()
  400. SpawnTrigger = false
  401. end
  402.  
  403. end
  404.  
  405. function SetUp()
  406. --print(self.getDescription().." is setting up!")
  407.  
  408. ShipTable = {}
  409. MyShip = nil
  410. CreateShipObjects()
  411. AssignMyShipName()
  412. CreateShipButtons()
  413. SettedUp = true
  414.  
  415. end
  416.  
  417. function CreateShipButtons()
  418. local Pos = {0, 0.1, -0.05}
  419.  
  420. local QuantPos = Pos
  421. QuantPos = {QuantPos[1], QuantPos[2], QuantPos[3] + 1}
  422. local PlusPos = Pos
  423. PlusPos = {PlusPos[1]+1, PlusPos[2], PlusPos[3] + 1}
  424. local NegPos = Pos
  425. NegPos = {NegPos[1]-1, NegPos[2], NegPos[3] + 1}
  426.  
  427.  
  428. ButtonHeight = 520
  429. ButtonWidth = 520
  430. ButtonColour = {0.05, 0.05, 0.05}
  431.  
  432. self.createButton({
  433. label=MyShip.Name, click_function='Nada', function_owner=self,
  434. position=Pos, height=550, width=1500, font_size=250, alignment=2, color = ButtonColour
  435. })
  436. self.createButton({
  437. label="x", click_function='Nada', function_owner=self,
  438. position=QuantPos, height=ButtonHeight, width=ButtonWidth, font_size=170, alignment=2, color = ButtonColour
  439. })
  440.  
  441. --this should pull a relevant ship from the bag into the counting area
  442. self.createButton({
  443. label="+", click_function='TakeShipFromBag', function_owner=self,
  444. position=PlusPos, height=ButtonHeight, width=ButtonWidth, font_size=300, alignment=2, color = ButtonColour
  445. })
  446.  
  447. --this should put a relevant ship out in the counting area back in the bag
  448. self.createButton({
  449. label="-", click_function='PutShipAway', function_owner=self,
  450. position=NegPos, height=ButtonHeight, width=ButtonWidth, font_size=300, alignment=2, color = ButtonColour
  451. })
  452.  
  453. end
  454.  
  455.  
  456. function AssignMyShipName()
  457. for i,j in ipairs(ShipTable) do
  458. if j.Name == self.getDescription() then
  459. MyShip = j
  460. --print("Assigned "..MyShip.Name.." to self.")
  461. end
  462. end
  463. end
  464.  
  465.  
  466. function NewShip(N, C, L)
  467. local Ship = {}
  468. Ship.Name = N
  469. Ship.Cost = C
  470. Ship.Limit = L
  471. table.insert(ShipTable, Ship)
  472. return Ship
  473. end
  474.  
  475. function CreateShipObjects()
  476. -- eventually expand this to include model file references etc
  477. destroyer = NewShip("Destroyer", 1, 8)
  478. cruiser = NewShip("Cruiser", 2, 8)
  479. warsun = NewShip("War Sun", 12, 2)
  480. infantry = NewShip("Infantry", 0.5, 12)
  481. fighter = NewShip("Fighter", 0.5, 10)
  482. carrier = NewShip("Carrier", 3, 4)
  483. dreadnought = NewShip("Dreadnought", 4, 5)
  484. flagship = NewShip("Flagship", 8, 1)
  485. end
  486.  
  487. function UpdateShipNumber()
  488.  
  489. if SeppukuPassed == true then
  490.  
  491. local n = 0
  492. for i, j in pairs(ShipBag.getObjects()) do
  493. if string.find(j.name, MyShip.Name) then
  494. n = n+1
  495.  
  496. end
  497. -- j.setColorTint(ShipBag.getColorTint())
  498. end
  499. self.editButton({index=1, label = tostring(n.."/"..MyShip.Limit)})
  500. MySpawner.setVar("EvaluateSwitch", true)
  501. end
  502.  
  503. end
  504.  
  505. function TakeShipFromBag()
  506.  
  507. local ShipFound = false
  508. for i, j in pairs(ShipBag.getObjects()) do
  509. if string.find(j.name, MyShip.Name) and ShipFound == false then
  510. params = {}
  511. params.guid = j.guid
  512. params.position = NewShipPosition()
  513. ShipBag.takeObject(params)
  514. ShipFound = true
  515. end
  516. end
  517. UpdateShipNumber()
  518. end
  519.  
  520. function NewShipPosition()
  521.  
  522. local length = #FindShipsInCountingArea()
  523. local SpawnOffset = {-3, 1, -4}
  524.  
  525. local x = MySpawner.getPosition()[1] + SpawnOffset[1] + 2*((length-2)%2)
  526. local y = MySpawner.getPosition()[2] + SpawnOffset[2]
  527. local z = MySpawner.getPosition()[3] + SpawnOffset[3] + 1.3*math.floor(length/2)
  528.  
  529. return {x, y, z}
  530. end
  531.  
  532. function PutShipAway()
  533. local ShipFound = false
  534. ShipsInCountingArea = CountingArea.getObjects()
  535.  
  536. for i, j in pairs(ShipsInCountingArea) do
  537. if string.find(j.getName(), MyShip.Name) and ShipFound == false then
  538. ShipBag.putObject(j)
  539. j.destruct()
  540. ShipFound = true
  541. end
  542. end
  543. UpdateShipNumber()
  544. end
  545.  
  546. function FindShipsInCountingArea()
  547. local ShipsInArea = {}
  548. for i, j in pairs(CountingArea.getObjects()) do
  549. if
  550. string.find(j.getName(), "Destroyer") or
  551. string.find(j.getName(), "Cruiser") or
  552. string.find(j.getName(), "Dreadnought") or
  553. string.find(j.getName(), "Carrier") or
  554. string.find(j.getName(), "Fighter") or
  555. string.find(j.getName(), "Infantry") or
  556. string.find(j.getName(), "Flagship") or
  557. string.find(j.getName(), "War Sun")
  558. then
  559. table.insert(ShipsInArea, j)
  560. end
  561. end
  562. return ShipsInArea
  563. end
  564.  
  565. function onObjectDestroyed(obj)
  566. --print("Object destroyed, evaluating...")
  567. if SeppukuPassed == true then
  568. if HasShipName(obj) then
  569. if HasMyShipbagColorTint(obj) then
  570. UpdateShipNumber()
  571. end
  572. end
  573. end
  574. end
  575.  
  576. function HasShipName(j)
  577. if
  578. string.find(j.getName(), "Destroyer") or
  579. string.find(j.getName(), "Cruiser") or
  580. string.find(j.getName(), "Dreadnought") or
  581. string.find(j.getName(), "Carrier") or
  582. string.find(j.getName(), "Fighter") or
  583. string.find(j.getName(), "Infantry") or
  584. string.find(j.getName(), "Flagship") or
  585. string.find(j.getName(), "War Sun")
  586. then return true
  587. else
  588. return false
  589. end
  590. end
  591.  
  592. function HasMyShipbagColorTint(obj)
  593.  
  594.  
  595. if
  596.  
  597. math.floor(obj.getColorTint()[1]*100) == math.floor(ShipBag.getColorTint()[1]*100) and
  598. math.floor(obj.getColorTint()[2]*100) == math.floor(ShipBag.getColorTint()[2]*100) and
  599. math.floor(obj.getColorTint()[3]*100) == math.floor(ShipBag.getColorTint()[3]*100)
  600. then return true
  601. else
  602. return false
  603. end
  604. end
  605.  
  606.  
  607. function onObjectEnterScriptingZone(zone, obj)
  608. if zone == CountingArea then
  609. UpdateShipNumber()
  610. --obj.setColorTint(ShipBag.getColorTint())
  611. end
  612. end
  613.  
  614.  
  615.  
  616. ]])
  617.  
  618. Blocc.setVar("MySpawner", self)
  619. Blocc.setVar("CountingArea", CountingArea)
  620. Blocc.setVar("ShipBag", ShipBag)
  621.  
  622. Blocc.setVar("SpawnTrigger", true)
  623.  
  624. Timer.create({identifier = 'BloccColorTimer:'..i..self.getGUID(), function_name = 'SetAllBloccColors', delay = 0.1})
  625.  
  626. --Blocc.lock()
  627. end
  628.  
  629.  
  630. end
  631.  
  632.  
  633. function SetAllBloccColors()
  634. for i,j in pairs(BloccTable) do
  635. SetBloccColor(j)
  636. end
  637. end
  638.  
  639. function LoccBloccs()
  640. for i,j in pairs(BloccTable) do
  641. j.lock()
  642. end
  643. end
  644.  
  645.  
  646. function SetSpawnPosition(v)
  647. s = self.getPosition()
  648. s = {s[1]+1.7, s[2]+0.35, s[3]-11.51+2.572*v}
  649. BloccParams.position = s
  650. BloccParams.rotation = {0, 90, 0}
  651. return s
  652. end
  653.  
  654. function NewShip(N, C, L)
  655. local Ship = {}
  656. Ship.Name = N
  657. Ship.Cost = C
  658. Ship.Limit = L
  659. table.insert(ShipTable, Ship)
  660. return Ship
  661. end
  662.  
  663. function CreateShipObjects()
  664. -- eventually expand this to include model file references etc
  665. destroyer = NewShip("Destroyer", 1, 8)
  666. cruiser = NewShip("Cruiser", 2, 8)
  667. warsun = NewShip("War Sun", 12, 2)
  668. infantry = NewShip("Infantry", 0.5, 12)
  669. fighter = NewShip("Fighter", 0.5, 10)
  670. carrier = NewShip("Carrier", 3, 4)
  671. dreadnought = NewShip("Dreadnought", 4, 5)
  672. flagship = NewShip("Flagship", 8, 1)
  673. end
  674.  
  675. function onObjectDrop(player_color, dropped_object)
  676. if dropped_object == self then
  677. Timer.create({identifier = 'BloccDropTimer:'..self.getGUID(), function_name = 'RepositionBloccs', delay = 1})
  678. end
  679. end
  680.  
  681. function RepositionBloccs()
  682. for i,j in pairs(BloccTable) do
  683. j.setPosition(SetSpawnPosition(i))
  684. end
  685. end
  686.  
  687. function ChangeMyColor(NewColor)
  688. --NewColor = self.getColorTint()
  689. SetColor = stringColorToRGB(NewColor)
  690. ShipBag.setColorTint(SetColor)
  691. local recolorthese = CountingArea.getObjects()
  692. for i,j in pairs(recolorthese) do
  693. if j.getName() == "Board" or j.getName() == "" then
  694. else
  695. j.setColorTint(SetColor)
  696. end
  697. end
  698. for i,j in pairs(BloccTable) do
  699. SetBloccColor(j)
  700. end
  701. SortSelfOut()
  702. RemoveColorButtons()
  703. end
  704.  
  705. function onObjectEnterScriptingZone(zone, obj)
  706. if zone == CountingArea then
  707. if IdentifyShip(obj) ~= nil then
  708. obj.setColorTint(ShipBag.getColorTint())
  709. EvaluateShips()
  710. end
  711. if string.find("PDS Space Dock Command Sheet", obj.getName()) and obj.getName() ~= "" then
  712. obj.setColorTint(ShipBag.getColorTint())
  713. self.setColorTint({0,0,0})
  714. end
  715. end
  716. end
  717.  
  718. function SpawnColorButtons()
  719. if ColorButtonsExist == 0 then
  720. local ColorXOffset = -15.5
  721. local ColorButtonOffset = 0.35
  722. local ColorButtonBeingCreated = 0
  723. local ColorButtonZOffset = 0.8
  724. local ColorButtonZOffset2ndRow = 1.2
  725.  
  726. self.createButton({
  727. label="", click_function='SetRed', function_owner=self,
  728. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset}, height=200, width=200, font_size=400, alignment=2
  729. })
  730.  
  731. ColorButtonBeingCreated = 1
  732. self.createButton({
  733. label="", click_function='SetOrange', function_owner=self,
  734. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset}, height=200, width=200, font_size=400, alignment=2
  735. })
  736.  
  737. ColorButtonBeingCreated = 2
  738. self.createButton({
  739. label="", click_function='SetYellow', function_owner=self,
  740. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset}, height=200, width=200, font_size=400, alignment=2
  741. })
  742.  
  743. ColorButtonBeingCreated = 3
  744. self.createButton({
  745. label="", click_function='SetGreen', function_owner=self,
  746. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset}, height=200, width=200, font_size=400, alignment=2
  747. })
  748.  
  749. ColorButtonBeingCreated = 4
  750. self.createButton({
  751. label="", click_function='SetTeal', function_owner=self,
  752. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset}, height=200, width=200, font_size=400, alignment=2
  753. })
  754.  
  755. ColorButtonBeingCreated = 0
  756. self.createButton({
  757. label="", click_function='SetBlue', function_owner=self,
  758. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset2ndRow}, height=200, width=200, font_size=400, alignment=2
  759. })
  760.  
  761. ColorButtonBeingCreated = 1
  762. self.createButton({
  763. label="", click_function='SetPurple', function_owner=self,
  764. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset2ndRow}, height=200, width=200, font_size=400, alignment=2
  765. })
  766.  
  767. ColorButtonBeingCreated = 2
  768. self.createButton({
  769. label="", click_function='SetPink', function_owner=self,
  770. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset2ndRow}, height=200, width=200, font_size=400, alignment=2
  771. })
  772.  
  773. ColorButtonBeingCreated = 3
  774. self.createButton({
  775. label="", click_function='SetWhite', function_owner=self,
  776. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset2ndRow}, height=200, width=200, font_size=400, alignment=2
  777. })
  778.  
  779. ColorButtonBeingCreated = 4
  780. self.createButton({
  781. label="", click_function='SetBrown', function_owner=self,
  782. position={ColorXOffset+(ColorButtonOffset*ColorButtonBeingCreated),ButtonHeight+0.1,ColorButtonZOffset2ndRow}, height=200, width=200, font_size=400, alignment=2
  783. })
  784. ColorButtonsExist = 1
  785. ColorColorButtons()
  786. else
  787.  
  788. end
  789. end
  790.  
  791. function SetRed()
  792. ChangeMyColor("Red")
  793. end
  794.  
  795.  
  796. function SetOrange()
  797. ChangeMyColor("Orange")
  798. end
  799.  
  800.  
  801. function SetYellow()
  802. ChangeMyColor("Yellow")
  803. end
  804.  
  805.  
  806. function SetGreen()
  807. ChangeMyColor("Green")
  808. end
  809.  
  810.  
  811. function SetTeal()
  812. ChangeMyColor("Teal")
  813. end
  814.  
  815.  
  816. function SetBlue()
  817. ChangeMyColor("Blue")
  818. end
  819.  
  820.  
  821. function SetPurple()
  822. ChangeMyColor("Purple")
  823.  
  824. end
  825.  
  826.  
  827. function SetPink()
  828. ChangeMyColor("Pink")
  829. end
  830.  
  831.  
  832. function SetWhite()
  833. ChangeMyColor("White")
  834. end
  835.  
  836.  
  837. function SetBrown()
  838. ChangeMyColor("Brown")
  839. end
  840.  
  841. function RemoveColorButtons()
  842. if ColorButtonsExist == 1 then do
  843. for v = 8,17,1 do
  844. self.removeButton(v)
  845. end
  846.  
  847. end
  848. ColorButtonsExist = 0
  849. end
  850.  
  851. end
  852.  
  853. function ColorColorButtons()
  854. Colors = {"Red", "Orange", "Yellow", "Green", "Teal", "Blue", "Purple", "Pink", "White", "Brown"}
  855. local ThisOne = 1
  856. for v = 8,17,1 do
  857. self.editButton({index = v, color = stringColorToRGB(Colors[ThisOne])})
  858. ThisOne = ThisOne + 1
  859. end
  860. end
  861.  
  862.  
  863. function Nada()
  864. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement