Advertisement
RedDeadlyCreeper

Scale E2

Dec 29th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. @name Building Scale Tool
  2. @outputs Update Dimensions:array Unit:string
  3. @persist [Dimensions Angles Positions Props PropPositions PropAngles]:array Unit:string
  4. @persist [LastPos]:vector
  5. @persist PropIndex Update UseCenterBlock UsePlayerReference DrawReferenceBlocks UseReferenceModel ReferenceModel:string ReferenceModelAlpha ReferenceModelAng:angle ReferenceModelOffset:vector ReferenceModelSkin:number
  6. @persist ReferenceModelClipOffset:vector ReferenceModelClipDir:vector
  7. @trigger
  8.  
  9. if(dupefinished()) { reset() }
  10.  
  11. if(first() | duped())
  12. {
  13. Dimensions = array(6.316/6.5, 3.56/6.5, 3/6.5) # Length, Width, Height ( green, red, blue )
  14. Unit = "m" # Meters
  15. #Unit = "in" # Inches
  16. #Unit = "..." # You can use any unit supported by fromUnit.
  17. DrawReferenceBlocks = 0 # Spawns props that can be used for easier alignment with PA.
  18. UseCenterBlock = 1 # Spawns a physical reference block in the center of the box.
  19. UsePlayerReference = 1 # Spawns a hologram player scale model.
  20. UseReferenceModel = 1 # Spawns a reference model, if you have one.
  21. ReferenceModel = "" # Reference model path
  22. ReferenceModelAng = ang() # Reference model angle
  23. ReferenceModelAlpha = 255 # Reference model alpha
  24. ReferenceModelSkin = 2
  25. #ReferenceModelOffset = vec(0,0,0) # Reference model offset vector
  26. ReferenceModelOffset = vec(0.27, 2, 0) # Reference model offset vector
  27. ReferenceModelClipOffset = vec(0,70,0)
  28. ReferenceModelClipDir = vec(0,1,1)
  29. # Don't edit below.
  30. for(I=1,3) # This scales it down to appropriate gmod size.... why I have to do this, not sure.
  31. {
  32. Dimensions[I, number] = Dimensions[I, number]*0.75 #1
  33. }
  34.  
  35. Angles = array(ang(90, 90, 0), ang(90, 0, 0), ang(0), ang(0))
  36. Positions = array(vec(0, fromUnit(Unit, Dimensions[1, number])/2, 0), vec(fromUnit(Unit, Dimensions[2, number])/2, 0, 0), vec(0, 0, fromUnit(Unit, Dimensions[3, number])/2), vec(fromUnit(Unit, Dimensions[2, number])/2, fromUnit(Unit, Dimensions[1, number])/2, fromUnit(Unit, Dimensions[3, number])/2))
  37. PropPositions = array(vec(1, 1, 1), vec(-1, 1, 1), vec(1, 1, -1), vec(-1, 1, -1), vec(0, 1, 0), vec(0, 1, 1), vec(0, 1, -1), vec(1, 1, 0), vec(-1, 1, 0), vec(1, -1, 1), vec(-1, -1, 1), vec(1, -1, -1), vec(-1, -1, -1), vec(0, -1, 0), vec(0, -1, 1), vec(0, -1, -1), vec(1, -1, 0), vec(-1, -1, 0), vec(1, 0, 0), vec(1, 0, 1), vec(1, 0, -1), vec(-1, 0, 0), vec(-1, 0, 1), vec(-1, 0, -1), vec(0, 0, 1), vec(0, 0, -1))
  38. PropAngles = array(ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(0, 0, 90), ang(90, 0, 0), ang(90, 0, 0), ang(90, 0, 0), ang(90, 0, 0), ang(90, 0, 0), ang(90, 0, 0), ang(0, 0, 0), ang(0, 0, 0))
  39. if(UseCenterBlock)
  40. {
  41. PropPositions:pushVector(vec())
  42. PropAngles:pushAngle(ang())
  43. }
  44. holoDeleteAll()
  45. for(I=1,Props:count())
  46. {
  47. Props[I, entity]:propDelete()
  48. }
  49. Props:clear()
  50. for(I=1,3)
  51. {
  52. Size = fromUnit(Unit, Dimensions[I, number])
  53. Ang = Angles[I, angle]
  54. Pos = Positions[I, vector]
  55. switch(I)
  56. {
  57. case 1,
  58. Col = vec(0, 255, 0)
  59. break
  60. case 2,
  61. Col = vec(255, 0, 0)
  62. break
  63. case 3,
  64. Col = vec(0, 0, 255)
  65. break
  66. }
  67. holoCreate(I)
  68. holoPos(I, entity():pos() + Pos + vec(0, 0, 5))
  69. holoAng(I, Ang)
  70. #holoModel(I, "cylinder")
  71. holoModel(I, "models/sprops/cylinders/size_1/cylinder_1_5x480.mdl")
  72. holoScaleUnits(I, vec(1, 1, Size))
  73. holoColor(I, vec4(Col, 50))
  74. holoMaterial(I, "models/wireframe")
  75. holoDisableShading(I, 1)
  76. }
  77.  
  78. holoCreate(4)
  79. holoPos(4, entity():pos() + Positions[4, vector]/2 + vec(0, 0, 5))
  80. holoAng(4, ang())
  81. holoModel(4, "models/sprops/cuboids/height48/size_1/cube_48x48x48.mdl")
  82. holoScaleUnits(4, Positions[4, vector]*2)
  83. holoColor(4, vec4(255, 255, 255, 50))
  84. holoMaterial(4, "models/wireframe")
  85. if(UsePlayerReference)
  86. {
  87. holoCreate(5)
  88. holoPos(5, holoEntity(4):toWorld(-holoScaleUnits(4)*vec(1, 0.5, 1)/2))
  89. holoAng(5, ang(0, 0, 0))
  90. holoColor(5, vec4(255, 255, 255, 128))
  91. holoModel(5, "models/editor/playerstart.mdl")
  92. holoParent(5, 4)
  93. }
  94. if(UseReferenceModel)
  95. {
  96. RefMdl = holoCreate(6)
  97. holoModel(6, ReferenceModel)
  98. holoPos(6, holoEntity(4):toWorld(-RefMdl:boxCenter() + ReferenceModelOffset))
  99. holoAng(6, ReferenceModelAng)
  100. holoAlpha(6, ReferenceModelAlpha)
  101. holoSkin(6, ReferenceModelSkin)
  102. holoClipEnabled(6,1)
  103. holoClip(6, ReferenceModelClipOffset, ReferenceModelClipDir, 0)
  104. holoParent(6, 4)
  105. }
  106. setName("Building Scale Tool\nDimensions: " + Dimensions[1, number] + "x" + Dimensions[2, number] + "x" + Dimensions[3, number] + Unit + " - " + floor(Positions[4, vector]:y()*2) + "x" + floor(Positions[4, vector]:x()*2) + "x" + floor(Positions[4, vector]:z()*2) + " gmod units")
  107. runOnLast(1)
  108. }
  109.  
  110. Pos = entity():pos()
  111. Dist = LastPos:distance(Pos)
  112.  
  113. if(Dist > 5)
  114. {
  115. Update = 1
  116. PropIndex = 1
  117. LastPos = Pos
  118. }
  119.  
  120. if(Update)
  121. {
  122. for(I=1,4)
  123. {
  124. holoPos(I, entity():pos() + Positions[I, vector] + vec(0, 0, 5))
  125. holoAng(I, Angles[I, angle])
  126. }
  127. if(!DrawReferenceBlocks) { Update = 0 }
  128. }
  129.  
  130. if(propCanCreate() & Props:count() < PropPositions:count() & DrawReferenceBlocks)
  131. {
  132. Prop = propSpawn("models/sprops/rectangles/size_1/rect_3x3x3.mdl", holoEntity(4):toWorld(holoScaleUnits(4)/2*PropPositions[Props:count()+1, vector]), PropAngles[Props:count()+1, angle], 1)
  133. #ifdef entity:noCollideAll(number) # Constraint core check
  134. Prop:noCollideAll(1)
  135. #endif
  136. Prop:setMaterial("models/wireframe")
  137. Prop:setColor(vec4(255, 255, 0, 128))
  138. Props:pushEntity(Prop)
  139. PropIndex = 1
  140. }elseif(Props:count() >= PropPositions:count())
  141. {
  142. if(Update)
  143. {
  144. Prop = Props[PropIndex, entity]
  145. Prop:setPos(holoEntity(4):toWorld(holoScaleUnits(4)/2*PropPositions[PropIndex, vector]))
  146. Prop:setAng(PropAngles[PropIndex, angle])
  147. Prop:propFreeze(1)
  148. PropIndex += 1
  149. if(PropIndex > Props:count()) { PropIndex = 1, Update = 0 }
  150. }
  151. }
  152.  
  153. if(last())
  154. {
  155. for(I=1,Props:count())
  156. {
  157. Props[I, entity]:propDelete()
  158. }
  159. exit()
  160. }
  161.  
  162. interval((Update ? 1 : 500))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement