Advertisement
KrazziPro

String Lights (Public E2)

Jan 14th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. @name Light string
  2.  
  3. @inputs End:entity
  4.  
  5. @persist Max:number ModelKabel:string ModelKugel:string LightMode:number Alpha:number Direction:number
  6. @persist LightBrightness:number LightDistance:number LightColor:vector
  7. @persist Pitch:number DirectionOfHanging:number
  8. @persist MaterialKable:string MaterialKugel:string
  9.  
  10. @model models/hunter/blocks/cube025x025x025.mdl
  11.  
  12. runOnTick(1)
  13. runOnLast(1)
  14.  
  15. E=entity()
  16.  
  17. if(first()) {
  18.  
  19. E = entity()
  20. E:setAlpha(0)
  21.  
  22. LightMode = 2 #Light Mode 1 = RGB | Mode 2 = Color from LightColor settings | Mode 3 = Random Color
  23. LightColor = vec(0,150,255) #Light Color ist fur Mode 2 die Farbe
  24.  
  25. MaterialKable = "debug/debugdrawflat" #Matrial for cable
  26. MaterialKugel = "debug/debugdrawflat" #Matrial for ball's
  27.  
  28. Max = 15 #Ball number
  29.  
  30. Direction = 0.5 #Hang direction 0.5 is the middle
  31.  
  32. DirectionOfHanging = 0 #Hang direction left or right
  33.  
  34. Pitch = 5 #How the cable hangs
  35.  
  36. ModelKabel = "cube" #Cable model
  37. ModelKugel = "hq_sphere" #Ball model
  38. Alpha = 255 #Model Alpha
  39.  
  40. LightBrightness = 1 #Light brightness
  41. LightDistance = 1 #Light distance
  42.  
  43. RandomeColor = vec(random(1,255),random(1,255),random(1,255)) #Create Randome colors
  44.  
  45. for(I=0,Max) { holoCreate(I) holoPos(I,E:pos()+vec(0,0,13*I)) Tar=E if(I>1) { Tar=holoEntity(I-1) } holoModel(I, ModelKugel) holoMaterial(I, MaterialKugel) holoScaleUnits(I, vec(6)) holoAlpha(I, Alpha) holoDisableShading(I, 1)
  46.  
  47. if(LightMode==1){
  48. holoColor(I, hsv2rgb(I*10, 1, 1))
  49.  
  50. }elseif(LightMode==2){
  51. holoColor(I, LightColor)
  52.  
  53. }elseif(LightMode==3){
  54. holoColor(I,RandomeColor)
  55.  
  56. }
  57. }
  58.  
  59. for(I=0+100,Max+100) { holoCreate(I) holoPos(I,E:pos()+vec(0,0,13*I)) Tar=E if(I>1) { Tar=holoEntity(I-1) } holoModel(I, ModelKabel) holoMaterial(I, MaterialKable) holoScaleUnits(I, vec(6)) holoColor(I, vec(0)) holoAlpha(I, 255) holoDisableShading(I, 1) }
  60.  
  61.  
  62.  
  63. #Check if LightCore is on the server
  64. #ifdef lightCreate(number,vector)
  65. for(A=0,Max) { lightCreate(A) lightPos(A,E:pos()+vec(0,0,13*A)) Tar=E if(A>1) { Tar=lightEntity(A-1) } lightBrightness(A, LightBrightness) lightDistance(A, LightDistance)
  66.  
  67. if(LightMode==1){
  68. lightColor(A,hsv2rgb(A*10, 1, 1))
  69.  
  70. }elseif(LightMode==2){
  71. lightColor(A,LightColor)
  72.  
  73. }elseif(LightMode==3){
  74. lightColor(A,RandomeColor)
  75.  
  76. }
  77. }
  78.  
  79. #endif
  80.  
  81. function vector makeRope(Start:vector,End:vector,Amount:number,Index:number) {
  82. local SplitDist = Start:distance(End)/Amount
  83. local Split = 1/Amount
  84. return bezier(Start,mix(End,Start,Direction)-vec(0,DirectionOfHanging,((Start-End):length())/Pitch),End,Split*Index)
  85. }
  86.  
  87. function void makeHoloRope(Index:number,IndexR:number,Dis:number) {
  88. E1=entity() if(IndexR>0) { E1=holoEntity(IndexR-1) }
  89. E2=End if(IndexR<Max) { E2=holoEntity(IndexR) }
  90.  
  91. holoPos(Index,E1:pos()+(E2:pos()-E1:pos())/2)
  92. holoScaleUnits(Index,vec(2,2,E1:pos():distance(E2:pos())))
  93. holoAng(Index,(E1:pos()-E2:pos()):toAngle()+ang(90,0,0))
  94.  
  95. }
  96.  
  97.  
  98. }
  99.  
  100. function setupProp(Parent:entity){
  101.  
  102. if(!End){
  103. findByModel("models/hunter/blocks/cube025x025x025.mdl")
  104. findSortByDistance(entity():pos())
  105.  
  106. if(find():owner()==owner()){
  107. End = find()
  108. }
  109.  
  110. }else{
  111.  
  112. if(!End:parent()){
  113.  
  114. if(End){
  115.  
  116. if(clk("load")){
  117. End:parentTo(Parent)
  118. End:setAlpha(0)
  119.  
  120. }
  121. }
  122. }
  123. }
  124. }
  125.  
  126. if(perf(1)){
  127. setupProp(E)
  128. }
  129. if(End&perf(10)) {
  130.  
  131. End:setAlpha(0)
  132.  
  133. for(A=0,Max){
  134. local Dis = E:pos():distance(End:pos())/Max
  135.  
  136. #Check if LightCore is on the server
  137. #ifdef lightCreate(number,vector)
  138. lightPos(A,makeRope(E:pos(),End:pos(),Max,A))
  139. #endif
  140.  
  141. makeHoloRope(A+100,A,Dis)
  142. }
  143.  
  144. for(I=0,Max) {
  145.  
  146. local Dis = E:pos():distance(End:pos())/Max
  147. holoPos(I,makeRope(E:pos(),End:pos(),Max,I))
  148. makeHoloRope(I+100,I,Dis)
  149.  
  150. }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement