Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. @name Entity [371][prop_physics]
  2. @inputs [Base]:entity
  3. @persist [HT CT]:table [SpawnStatus CoreStatus]:string [HN CN I SpawnCounter]
  4. @persist [Base]:entity [ScaleFactor ToggleColMat ToggleShading] Indices
  5. @persist [DefaultColor DefaultScale]:vector
  6.  
  7. if (first() | dupefinished())
  8. {
  9. Chip = entity()
  10.  
  11. Indices = 1
  12. ScaleFactor = 1
  13. ToggleColMat = 1
  14. ToggleShading = 0
  15.  
  16. #- Data structure
  17. #- HN++, HT[HN, table] = table(Index, Parent, ScaleType (Default 0), Pos, Ang, Scale, Model, Material, Color, Skin, Bodygroup Index, Bodygroup Sub-Index)
  18.  
  19. # # # # # # # # # HOLOGRAM DATA START # # # # # # # # #
  20.  
  21. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 0, 0), ang(-70, -180, 90), vec(0.756, 0.756, 0.8618), "models/mechanics/wheels/wheel_rugged_48.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  22.  
  23. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.65, 0.825, 1.65), "models/sprops/geometry/fdisc_18.mdl", "", vec4(255, 255, 255, 255), 0)
  24.  
  25. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.103, 0.4798, 1.103), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  26.  
  27. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.025, 0.4817, 1.025), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  28.  
  29. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(0.975, 0.4875, 0.975), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  30.  
  31. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.175, 1.0575, 1.175), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  32.  
  33. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(0.9, 0.486, 0.9), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
  34.  
  35. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 0.714, 0), ang(0, 0, -90), vec(2.3, 2.3, 0.46), "models/sprops/misc/cones/size_1/cone_12x12.mdl", "", vec4(255, 255, 255, 255), 0)
  36. CN++, CT[CN,table] = table(I, 1, vec(0, 0, 2.9207), vec(0, 0, -1))
  37.  
  38. I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 2.1576, 0), ang(0, 0, 0), vec(1.09, 0.9592, 1.09), "models/sprops/geometry/fdisc_12.mdl", "", vec4(255, 255, 255, 255), 0)
  39.  
  40. # # # # # # # # # HOLOGRAM DATA END # # # # # # # # #
  41.  
  42. #- Create a hologram from data array
  43. function table:holo() {
  44. local Index = This[1, number] * Indices
  45. local Entity = This[2, entity]
  46. local Parent = This[2, entity]
  47. local Rescale = (This[6, vector] / (This[3, number] ? 12 : 1)) * ScaleFactor
  48.  
  49. holoCreate(Index, Entity:toWorld(This[4, vector] * ScaleFactor), Rescale, Entity:toWorld(This[5, angle]), DefaultColor, This[7, string] ?: "cube")
  50. holoParent(Index, Parent)
  51.  
  52. if (ToggleColMat) {
  53. holoMaterial(Index, This[8, string])
  54. holoColor(Index, This[9, vector4])
  55. holoSkin(Index, This[10, number])
  56. holoBodygroup(Index, This[11, number], This[12, number])
  57. }
  58.  
  59. if (ToggleShading) { holoDisableShading(Index, 1) }
  60. }
  61.  
  62. #- Clip a hologram from data array
  63. function table:clip() {
  64. holoClipEnabled(This[1, number] * Indices, This[2, number], 1)
  65. holoClip(This[1, number] * Indices, This[2, number], This[3, vector] * ScaleFactor, This[4, vector], 0)
  66. }
  67.  
  68. #- Load the contraption
  69. function loadContraption() {
  70. switch (SpawnStatus) {
  71. case "InitSpawn",
  72. if (clk("Start")) {
  73. SpawnStatus = "LoadHolograms"
  74. }
  75. Chip:soundPlay("Blip", 0, "@^garrysmod/content_downloaded.wav", 0.212)
  76. break
  77.  
  78. case "LoadHolograms",
  79. while (perf() & holoCanCreate() & SpawnCounter < HN) {
  80. SpawnCounter++
  81. HT[SpawnCounter, table]:holo()
  82.  
  83. if (SpawnCounter >= HN) {
  84. SpawnStatus = CN > 0 ? "LoadClips" : "PrintStatus"
  85. SpawnCounter = 0
  86. break
  87. }
  88. }
  89. break
  90.  
  91. case "LoadClips",
  92. while (perf() & SpawnCounter < CN) {
  93. SpawnCounter++
  94. CT[SpawnCounter, table]:clip()
  95.  
  96. if (SpawnCounter >= CN) {
  97. SpawnStatus = "PrintStatus"
  98. SpawnCounter = 0
  99. break
  100. }
  101. }
  102. break
  103.  
  104. case "PrintStatus",
  105. printColor( vec(222,37,188), "PAC to Holo: ", vec(255,255,255), "Loaded " + HN + " holograms and " + CN + " clips." )
  106.  
  107. HT:clear()
  108. CT:clear()
  109.  
  110. CoreStatus = "InitPostSpawn"
  111. SpawnStatus = ""
  112. break
  113. }
  114. }
  115.  
  116. CoreStatus = "InitSpawn"
  117. SpawnStatus = "InitSpawn"
  118.  
  119. DefaultColor = vec(255, 255, 255)
  120.  
  121. runOnTick(1)
  122. timer("Start", 500)
  123. }
  124.  
  125. # Credit to Shadowscion for the initial base hologram spawning code.
  126.  
  127. elseif (CoreStatus == "InitSpawn")
  128. {
  129. loadContraption()
  130. }
  131. elseif (CoreStatus == "InitPostSpawn")
  132. {
  133. # This is your "if (first())" section of the code.
  134.  
  135. CoreStatus = "RunThisCode"
  136. }
  137. elseif (CoreStatus == "RunThisCode")
  138. {
  139. # This is your interal ran section of the code.
  140.  
  141. runOnTick(0)
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement