Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Building Scale Tool
- @outputs Update Dimensions:array Unit:string
- @persist [Dimensions Angles Positions Props PropPositions PropAngles]:array Unit:string
- @persist [LastPos]:vector
- @persist PropIndex Update UseCenterBlock UsePlayerReference DrawReferenceBlocks UseReferenceModel ReferenceModel:string ReferenceModelAlpha ReferenceModelAng:angle ReferenceModelOffset:vector ReferenceModelSkin:number
- @persist ReferenceModelClipOffset:vector ReferenceModelClipDir:vector
- @trigger
- if(dupefinished()) { reset() }
- if(first() | duped())
- {
- Dimensions = array(6.316/6.5, 3.56/6.5, 3/6.5) # Length, Width, Height ( green, red, blue )
- Unit = "m" # Meters
- #Unit = "in" # Inches
- #Unit = "..." # You can use any unit supported by fromUnit.
- DrawReferenceBlocks = 0 # Spawns props that can be used for easier alignment with PA.
- UseCenterBlock = 1 # Spawns a physical reference block in the center of the box.
- UsePlayerReference = 1 # Spawns a hologram player scale model.
- UseReferenceModel = 1 # Spawns a reference model, if you have one.
- ReferenceModel = "" # Reference model path
- ReferenceModelAng = ang() # Reference model angle
- ReferenceModelAlpha = 255 # Reference model alpha
- ReferenceModelSkin = 2
- #ReferenceModelOffset = vec(0,0,0) # Reference model offset vector
- ReferenceModelOffset = vec(0.27, 2, 0) # Reference model offset vector
- ReferenceModelClipOffset = vec(0,70,0)
- ReferenceModelClipDir = vec(0,1,1)
- # Don't edit below.
- for(I=1,3) # This scales it down to appropriate gmod size.... why I have to do this, not sure.
- {
- Dimensions[I, number] = Dimensions[I, number]*0.75 #1
- }
- Angles = array(ang(90, 90, 0), ang(90, 0, 0), ang(0), ang(0))
- 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))
- 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))
- 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))
- if(UseCenterBlock)
- {
- PropPositions:pushVector(vec())
- PropAngles:pushAngle(ang())
- }
- holoDeleteAll()
- for(I=1,Props:count())
- {
- Props[I, entity]:propDelete()
- }
- Props:clear()
- for(I=1,3)
- {
- Size = fromUnit(Unit, Dimensions[I, number])
- Ang = Angles[I, angle]
- Pos = Positions[I, vector]
- switch(I)
- {
- case 1,
- Col = vec(0, 255, 0)
- break
- case 2,
- Col = vec(255, 0, 0)
- break
- case 3,
- Col = vec(0, 0, 255)
- break
- }
- holoCreate(I)
- holoPos(I, entity():pos() + Pos + vec(0, 0, 5))
- holoAng(I, Ang)
- #holoModel(I, "cylinder")
- holoModel(I, "models/sprops/cylinders/size_1/cylinder_1_5x480.mdl")
- holoScaleUnits(I, vec(1, 1, Size))
- holoColor(I, vec4(Col, 50))
- holoMaterial(I, "models/wireframe")
- holoDisableShading(I, 1)
- }
- holoCreate(4)
- holoPos(4, entity():pos() + Positions[4, vector]/2 + vec(0, 0, 5))
- holoAng(4, ang())
- holoModel(4, "models/sprops/cuboids/height48/size_1/cube_48x48x48.mdl")
- holoScaleUnits(4, Positions[4, vector]*2)
- holoColor(4, vec4(255, 255, 255, 50))
- holoMaterial(4, "models/wireframe")
- if(UsePlayerReference)
- {
- holoCreate(5)
- holoPos(5, holoEntity(4):toWorld(-holoScaleUnits(4)*vec(1, 0.5, 1)/2))
- holoAng(5, ang(0, 0, 0))
- holoColor(5, vec4(255, 255, 255, 128))
- holoModel(5, "models/editor/playerstart.mdl")
- holoParent(5, 4)
- }
- if(UseReferenceModel)
- {
- RefMdl = holoCreate(6)
- holoModel(6, ReferenceModel)
- holoPos(6, holoEntity(4):toWorld(-RefMdl:boxCenter() + ReferenceModelOffset))
- holoAng(6, ReferenceModelAng)
- holoAlpha(6, ReferenceModelAlpha)
- holoSkin(6, ReferenceModelSkin)
- holoClipEnabled(6,1)
- holoClip(6, ReferenceModelClipOffset, ReferenceModelClipDir, 0)
- holoParent(6, 4)
- }
- 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")
- runOnLast(1)
- }
- Pos = entity():pos()
- Dist = LastPos:distance(Pos)
- if(Dist > 5)
- {
- Update = 1
- PropIndex = 1
- LastPos = Pos
- }
- if(Update)
- {
- for(I=1,4)
- {
- holoPos(I, entity():pos() + Positions[I, vector] + vec(0, 0, 5))
- holoAng(I, Angles[I, angle])
- }
- if(!DrawReferenceBlocks) { Update = 0 }
- }
- if(propCanCreate() & Props:count() < PropPositions:count() & DrawReferenceBlocks)
- {
- 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)
- #ifdef entity:noCollideAll(number) # Constraint core check
- Prop:noCollideAll(1)
- #endif
- Prop:setMaterial("models/wireframe")
- Prop:setColor(vec4(255, 255, 0, 128))
- Props:pushEntity(Prop)
- PropIndex = 1
- }elseif(Props:count() >= PropPositions:count())
- {
- if(Update)
- {
- Prop = Props[PropIndex, entity]
- Prop:setPos(holoEntity(4):toWorld(holoScaleUnits(4)/2*PropPositions[PropIndex, vector]))
- Prop:setAng(PropAngles[PropIndex, angle])
- Prop:propFreeze(1)
- PropIndex += 1
- if(PropIndex > Props:count()) { PropIndex = 1, Update = 0 }
- }
- }
- if(last())
- {
- for(I=1,Props:count())
- {
- Props[I, entity]:propDelete()
- }
- exit()
- }
- interval((Update ? 1 : 500))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement