• Make an entity out of brushes in hammer
    3 replies, posted
I don't know if this should go into mapping or lua. Does anyone know how to make a brush entity in hammer that I could do Entity functions on and possibly set some keyvalues?
It's quite simple really: * Make a brush * Select it & Ctrl-T to tie it to an entity. * Enter whatever name you like in the class box. * Make a new directory in your <gamemode>/entities/entities/ dir. Name it the same as the classname you used in hammer. * Make a init.lua file in this dir and put [i]ENT.Type = "brush"[/i] at the top. * All done. If you want to add any key values to your ent in hammer you'll have to turn smart edit off when editing the ents properties, or add your classname to the active FDG settings file. Here's an example brush ent which is being used as a trigger... entities/entities/trigger_capzone/init.lua [lua] ENT.Type = "brush" /*--------------------------------------------------------- Name: Initialize ---------------------------------------------------------*/ function ENT:Initialize() self.Team = self.Team or RED_TEAM self.EnterSound = "npc/combine_gunship/gunship_ping_search.wav" self.ExitSound = "npc/combine_gunship/attack_stop2.wav" end /*--------------------------------------------------------- Name: StartTouch ---------------------------------------------------------*/ function ENT:StartTouch( entity ) if ( !self:PassesTriggerFilters( entity ) ) then return end self:DoScoring( entity, true ) end /*--------------------------------------------------------- Name: EndTouch ---------------------------------------------------------*/ function ENT:EndTouch( entity ) if ( !self:PassesTriggerFilters( entity ) ) then return end self:DoScoring( entity, false ) end function ENT:DoScoring( head, bool ) //stuff here end /*--------------------------------------------------------- Name: PassesTriggerFilters ---------------------------------------------------------*/ function ENT:PassesTriggerFilters( entity ) return ( entity && entity:IsValid() && entity:GetClass() == "hh_head" ) && ( entity:GetPlayer() && entity:GetPlayer():IsValid() ) end /*--------------------------------------------------------- Name: KeyValue, Called when a key is defined in hammer ---------------------------------------------------------*/ function ENT:KeyValue( key, value ) self:SetNWString( key, value ) end [/lua]
Okay, I made the brush in hammer but when I go in-game the brush doesn't show up, any reason why? entities/entities/func_fade/init.lua [lua] ENT.Type = "brush" function ENT:Initialize() end function ENT:KeyValue(key, value) end [/lua]
self.Draw() ... Edit: SHIT SORRY FOR THE GRAVEDIGGING
Sorry, you need to Log In to post a reply to this thread.