• Prop-er (Har Har) way to make a prop with lua?
    7 replies, posted
Allright, so this has annoyed me for a while now. Anyone care to give me some sample code on how to make a prop properly with pure lua? All the techniques I try either: - don't have physics for the player spawning it, but works for everyone else - has physics for players, but not other props - Have odd physics that seem to be out of sync with the client's positioning of it. - No physics at all I've tried just about everything. Setting collision groups, waking the physics multiple times, setting it to a solid, changing the move type, etc. yet it does not seem to want to work properly. Calling GM.Spawn doesn't seem to be working with this either. And before I am asked, this is model independent.
Proper is actually a thing for Hammer Editor. I don't think you can create models using lua and then spawn them whenever you want. The only thing I can come to think of is IMesh, but it also won't save anything to .mdl
[lua]local prop = ents.Create("prop_physics") prop:SetModel("model_name_goes_here.mdl") prop:Spawn()[/lua]
If you're not using prop_physics, try this. Serverside: [lua]function ENT:Initialize() self:SetModel("your/model/here.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end end[/lua]
[QUOTE=CGNick;40374752] local prop = ents.Create("prop_physics") prop:SetModel("model_name_goes_here.mdl") prop:Spawn() [/QUOTE] That's what I've done initially, as well as I have ever had to do, but it results in the case listed in the OP: It has physics for everyone but not other props. [editline]22nd April 2013[/editline] [QUOTE=Netheous;40374560]Proper is actually a thing for Hammer Editor. I don't think you can create models using lua and then spawn them whenever you want. The only thing I can come to think of is IMesh, but it also won't save anything to .mdl[/QUOTE] I wasn't asking how to make a .mdl file. The title was just a pun. Sorry for the confusion. I need to spawn any given model and have physics work. [editline]22nd April 2013[/editline] Just so we are all informed: What I am doing: [code] function SpawnProp(len, ply) local tr = ply:TraceFromEyes(200) local pos = tr.HitPos + Vector(0,0,20) local prop = ents.Create("prop_physics") prop:SetModel(net.ReadString()) prop:SetPos(pos) prop:SetOwner(ply) prop:SetSolid( SOLID_VPHYSICS ) prop:PhysicsInit( SOLID_VPHYSICS ) prop:SetCollisionGroup( COLLISION_GROUP_PLAYER ) prop:Spawn() end [/code] I changed out the sold, physics, and collisions groups to every combination possible with no luck, only to have the issues in OP
[QUOTE=CGNick;40374752][lua]local prop = ents.Create("prop_physics") prop:SetModel("model_name_goes_here.mdl") prop:Spawn()[/lua][/QUOTE] If this doesn't work how it should, you're most likely having some conflicting scripts/code somewhere.
[QUOTE=find me;40379280]If this doesn't work how it should, you're most likely having some conflicting scripts/code somewhere.[/QUOTE] And that's exactly why this is frustrating me to the ends of the earth. I was thinking it was an issue with my server, which I may just do a quick reinstall to see if that fixes it. I just wanted to post here and see to make sure I wasn't being a complete dipshit.
-snip- I think this is a bug. Posted a thread here: [url]http://facepunch.com/showthread.php?t=1266342&p=40438975#post40438975[/url]
Sorry, you need to Log In to post a reply to this thread.