• Lua entitys inside a map?
    6 replies, posted
Hello, I am working on some entitys made from Lua and i don't know how i would set the KetValues in the map, and retrieve them in Lua. Simple stuff like angle , Vector, and a custom key-value. Would anyone be able to explain this to me? thanks in advance
Add them to your FGD like so: [code] //------------------------------------------------------------------------- // // Solid Classes // //------------------------------------------------------------------------- @SolidClass base(TeamNum) = func_checkpoint : "Volume that determines a checkpoint. A player that reaches this checkpoint fires it off for the entire team." [ checkpointnum(integer) : "Checkpoint Number: " : 0 : "Which checkpoint is this? Starts at 0." ][/code] Then in your entity (Say a func_checkpoint) do: [lua] ENT.Type = "brush" ENT.CheckpointNum = -1 AddCSLuaFile( "shared.lua" ) function ENT:KeyValue(k,v) if k == "checkpointnum" then self.CheckpointNum = tonumber(v) end end[/lua] Place that inside the shared.lua. It'll automatically read the KeyValues when spawned and set ENT.CheckpointNum to self.CheckpointNum.
How would i do it with point entitys? [editline]3rd December 2010[/editline] and where is the FDG?
FDG's are found in sourcesdk\bin\orangebox\bin Example of a pointclass. [code] @PointClass base(Angles) studioprop("models/props_junk/sawblade001a.mdl") = lounge_top10 : "Top10 Scoreboard" [ ] [/code]
Generally one has to make the FGD.
Yes, but also, for some reason, Entity:GetAngles doesn't work on my entity, it always returns Angle( 0 , 0, 0). Anyway, thanks for the help
I had issues getting the position of a brush-entity that was in the map... Finally did: [lua] for f,u in pairs( ents.FindByClass("func_checkpoint")) do --print(tostring(k)..tostring(v)) print("Checkpoint Num: "..tostring(u.CheckpointNum)) print("Team Num: "..tostring(u.Team)) if (u.CheckpointNum == 0 && u.Team == 2) then --ORANGE checkpoint1Position = u:LocalToWorld(u:OBBCenter()) print("Checkpoint1Position: "..tostring(checkpoint1Position)) end if (u.CheckpointNum == 1 && u.Team == 2) then --ORANGE checkpoint2Position = u:LocalToWorld(u:OBBCenter()) end if (u.CheckpointNum == 2 && u.Team == 2) then --ORANGE print("checkpoint3Position blah") checkpoint3Position = u:LocalToWorld(u:OBBCenter()) end if (u.CheckpointNum == 3 && u.Team == 2) then --ORANGE checkpoint4Position = u:LocalToWorld(u:OBBCenter()) end end [/lua] So you might have to try some of the other functions.
Sorry, you need to Log In to post a reply to this thread.