Scripted Entities
Scripted Entities (or SENTs for short) are custom entities coded entirely in Lua.
They are usually defined in a separate .lua
file in the lua/entities/
folder.
The difference from Engine Entities being that you cannot use ENTITY Hooks on engine entities.
Scripted Entity Types
There are 6 different types of Scripted Entities:
ENT.Type | Description |
---|---|
nextbot | A NextBot NPC. A newer-type NPCs with better navigation. All NextBot functions and hooks are also usable on these entities. |
anim | A normal entity with visual and/or physical presence in the game world, such as props or whatever else you can imagine. |
brush | A serverside only trigger entity. Mostly used very closely with the Hammer Level Editor. |
point | A usually serverside only entity that doesn't have a visual or physical representation in the game world, such as logic entities. |
filter | A different kind of "point" entity used in conjunction with trigger (brush type) entities. |
ai | 2004 Source Engine NPC system entity |
Scripting
The following is usable with Scripted Entities:
- ENT structure
- ENTITY hooks
- Entity functions
The following is usable with Scripted Weapons (Also known as SWEPs):
- SWEP structure
- Entity functions
- Weapon functions
- WEAPON hooks
The following example scripts are placed within lua/entities
. If you would like a more in-depth tutorial on entity creation, click here
Example
A plain single-file SENT script that runs on client and server. You can name the file barrel.lua
or place it in a folder named barrel
and name it shared.lua
. Creates a barrel with physics that can be destroyed.
Example
A SENT made up of three scripts, make sure to put these within a folder named after your entity. Creates a barrel with physics that can be destroyed.