How to code/place brush entities?

The closest thing to a tutorial I can find is the wiki saying to throw ENT.Type = “brush” in. I just need to know how to place them and how to get the boundaries of them.

Why do you need to get their boundaries? And you gotta place them through hammer, unless you want to generate the mesh for it in Lua, but that’s far from easy.

I want to make some kind of item spawn areas in a map, and it’d be incredibly easy to just drop in brushes in hammer as opposed to defining them manually for each map.

Triggers aren’t really designed for this. There’s no easy way to get their boundaries, if there’s any at all.

Look at TTT’s source code:

It has some methods for determining if a point is inside its brush or not

[editline]7th June 2014[/editline]

It’s not a trigger necessarily, just a brush entity. Look at the link I posted, it looks pretty easy to me
[edit]

Actually, it’s not the VectorInside function you want, it’s the bounding box functions a few lines down
http://gmodwiki.net/Lua/Classes/Entity/OBBMins
Gives you the vector of the entity’s lowest corner in its bounding box (which for a brush entity is the brush)
There’s a corresponding one for the highest corner as well.

[editline]7th June 2014[/editline]

In all honesty it’d be easier to create a GMod Toolgun script similar to the TTT Map Rearmer. You could make it have certain settings for radius, item types and so on. You could even have it visually display the radius before and after placing the spawns. You can then output the location, radius and other information into a text document. It’ll also allow more maps to be compatible with your gamemode more easily, rather than manually editing them in Hammer.

I haven’t heard of the tool, but it sounds better than what I had in mind. Thanks for the advice!

You can use this to make custom “trigger brushes”

entities/some_ent/init.lua – server sided only


ENT.Base = "base_brush"
ENT.Type = "brush"

-- Updates the bounds of this collision box
function ENT:SetBounds(min, max)
    self:SetSolid(SOLID_BBOX)
    self:SetCollisionBounds(min, max)
    self:SetTrigger(true)
end

-- Run when any entity starts touching our trigger
function ENT:StartTouch(ent)
    if ent:IsPlayer() then
        ent:Give("weapon_crowbar")
    end
end