Advertisement
CapsAdmin

Untitled

Mar 5th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. local MODEL = "models/XQM/Rails/gumball_1.mdl"
  2. MODEL = MODEL:lower()
  3.  
  4. if SERVER then
  5.     jit.on(true, true)
  6.     jit.opt.start(3)
  7.    
  8.     if cupcakes then
  9.         for k, v in ipairs(cupcakes) do
  10.             SafeRemoveEntity(v)
  11.         end
  12.     end
  13.    
  14.     cupcakes_res = 64
  15.     cupcakes = {}
  16.    
  17.     for i = 1, 128 do
  18.         local ent = ents.Create("prop_physics")
  19.    
  20.         ent:SetModel(MODEL)
  21.         ent:SetPos(asdf + Vector(0, 1, 1):GetNormal() * cupcakes_res * i)
  22.         ent:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
  23.         ent:Spawn()
  24.         ent:SetSkin(i)
  25.         ent:PhysicsInitSphere(1)
  26.        
  27.         local phys = ent:GetPhysicsObject()
  28.         phys:SetMass(0.01)
  29.         phys:SetDamping(0,0)
  30.         phys:SetMaterial("jeeptire")
  31.        
  32.        
  33.         dist = ent:BoundingRadius() / 2
  34.    
  35.         cupcakes[i] = ent
  36.     end
  37.    
  38.     local real_length = 1
  39.     real_length = real_length * real_length
  40.    
  41.     local function lol(x, y)
  42.         local offset = y:GetPos() - x:GetPos()
  43.         local phys = x:GetPhysicsObject()
  44.         local len = offset:LengthSqr()
  45.         local vel = len - real_length
  46.        
  47.         if vel > real_length then
  48.             phys:SetVelocity(Vector())---???????
  49.         end
  50.        
  51.         vel = vel * 0.075
  52.        
  53.         phys:AddVelocity(offset:GetNormal() * vel)
  54.         phys:AddVelocity(phys:GetVelocity() * -math.Clamp(len/1000000, 0.00001, 0.02))
  55.        
  56.         phys:AddAngleVelocity(phys:GetAngleVelocity()*-1)
  57.     end
  58.    
  59.     hook.Add("Think", "a", function()
  60.         for i = 2, #cupcakes do
  61.             lol(cupcakes[i - 1], cupcakes[i])
  62.             lol(cupcakes[i], cupcakes[i - 1])
  63.         end
  64.     end)
  65. end
  66.  
  67. if CLIENT then 
  68.     local mat = Material("cable/rope")
  69.    
  70.     hook.Add("PostDrawTranslucentRenderables", "rope", function()
  71.         local balls = {}
  72.            
  73.         for k,v in pairs(ents.GetAll()) do
  74.             local mdl = v:GetModel()
  75.             if mdl and mdl:lower() == MODEL and v:GetSkin() > 0 then
  76.                 table.insert(balls, v)
  77.                 v:SetNoDraw(true)
  78.             end
  79.         end
  80.         local count = #balls
  81.                
  82.         table.sort(balls, function(a,b) return a:GetSkin() > b:GetSkin() end)
  83.            
  84.         render.SetMaterial(mat)
  85.            
  86.         render.StartBeam(#balls)
  87.            
  88.         for k,v in pairs(balls) do
  89.             render.AddBeam(v:GetPos(), 20, k/count, HSVToColor((k/count)*360, 0.75, 1))
  90.         end
  91.            
  92.         render.EndBeam()
  93.     end)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement