Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MODEL = "models/XQM/Rails/gumball_1.mdl"
- MODEL = MODEL:lower()
- if SERVER then
- jit.on(true, true)
- jit.opt.start(3)
- if cupcakes then
- for k, v in ipairs(cupcakes) do
- SafeRemoveEntity(v)
- end
- end
- cupcakes_res = 64
- cupcakes = {}
- for i = 1, 128 do
- local ent = ents.Create("prop_physics")
- ent:SetModel(MODEL)
- ent:SetPos(asdf + Vector(0, 1, 1):GetNormal() * cupcakes_res * i)
- ent:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
- ent:Spawn()
- ent:SetSkin(i)
- ent:PhysicsInitSphere(1)
- local phys = ent:GetPhysicsObject()
- phys:SetMass(0.01)
- phys:SetDamping(0,0)
- phys:SetMaterial("jeeptire")
- dist = ent:BoundingRadius() / 2
- cupcakes[i] = ent
- end
- local real_length = 1
- real_length = real_length * real_length
- local function lol(x, y)
- local offset = y:GetPos() - x:GetPos()
- local phys = x:GetPhysicsObject()
- local len = offset:LengthSqr()
- local vel = len - real_length
- if vel > real_length then
- phys:SetVelocity(Vector())---???????
- end
- vel = vel * 0.075
- phys:AddVelocity(offset:GetNormal() * vel)
- phys:AddVelocity(phys:GetVelocity() * -math.Clamp(len/1000000, 0.00001, 0.02))
- phys:AddAngleVelocity(phys:GetAngleVelocity()*-1)
- end
- hook.Add("Think", "a", function()
- for i = 2, #cupcakes do
- lol(cupcakes[i - 1], cupcakes[i])
- lol(cupcakes[i], cupcakes[i - 1])
- end
- end)
- end
- if CLIENT then
- local mat = Material("cable/rope")
- hook.Add("PostDrawTranslucentRenderables", "rope", function()
- local balls = {}
- for k,v in pairs(ents.GetAll()) do
- local mdl = v:GetModel()
- if mdl and mdl:lower() == MODEL and v:GetSkin() > 0 then
- table.insert(balls, v)
- v:SetNoDraw(true)
- end
- end
- local count = #balls
- table.sort(balls, function(a,b) return a:GetSkin() > b:GetSkin() end)
- render.SetMaterial(mat)
- render.StartBeam(#balls)
- for k,v in pairs(balls) do
- render.AddBeam(v:GetPos(), 20, k/count, HSVToColor((k/count)*360, 0.75, 1))
- end
- render.EndBeam()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement