• How to make wires? (NOT Wiremod)
    10 replies, posted
What I mean is: What's the code to make a rope that doesn't have any slack, doesn't collide with the world, isn't a constraint, stretches indefinitely, and so forth (like Wiremod wires)? Is it along the lines of the "render.StartBeam" stuff, or is it something else entirely? I tried looking at how Wiremod does it, but I can't understand their code for sh*t. Also, what is, in your opinion, the best way for SENTs to communicate arbitrary data to eachother?
The visible ropes/wires are done with render.DrawBeam, IIRC. However, this does nothing to communicate data, just makes the wires appear.
Ah, I thought as much. I don't suppose you have a bit of sample code showing me how to do it?
[url=http://wiki.garrysmod.com/?title=Render.DrawBeam]Here.[/url]
Ah, thank you. So, I suppose I'd have Vector1 be the location of one prop, and Vector2 be the location of the other? Would this automatically track the two props, or would this have to be under a Think, updating constantly?
It'd have to be under a draw hook, like HudPaint or PostRenderEffects or something like that.
Or just look at enginemod if you want a better example.
infact why not just use the contraint elastic? With all settings at zero it's just what you're looking for.
Would that cause any extra physics lag?
Follow instructions carefully; [lua] TOOL.Category = "Constraints" TOOL.Name = "#Elastic Mega" total = 0 if ( CLIENT ) then language.Add( "Tool_megaconstraint_name", "Stupid constraint test" ) language.Add( "Tool_megaconstraint_desc", "try resist spamming, although fun." ) language.Add ("Tool_megaconstraint_0", "LeftClick: Select first prop, RightClick: Select second prop, Reload: SPAMMY SPAM CONSTRAINT Love from JSharpe") end function TOOL:LeftClick( trace ) if (!trace.Entity) then return false end if (!trace.Entity:IsValid() ) then return false end if (trace.Entity:IsPlayer()) then return false end if (trace.Entity:IsWorld()) then return false end Ent1 = trace.Entity end function TOOL:RightClick( trace ) if (!trace.Entity) then return false end if (!trace.Entity:IsValid() ) then return false end if (trace.Entity:IsPlayer()) then return false end if (trace.Entity:IsWorld()) then return false end Ent2 = trace.Entity end function TOOL:Reload( trace ) local ammount = 10 for i=0, ammount do total = total + 1 local randLVec = Vector( math.random(-10, 10), math.random(-10, 10), math.random(-10, 10) ) local constraint, rope = constraint.Elastic( Ent1, Ent2, 0, 0, randLVec, randLVec, 0, 0, 0, "cable/cable", 1, 0) end print(total) end [/lua] It's a silly stool i just did for testing. Place in gamemodes/sandbox/entites/weapons/gmod_tool/stools as whatever.lua
It causes no physics lag, then? Excellent. Thanks for the code. *goes to start testing stuff*
Sorry, you need to Log In to post a reply to this thread.