Making an entity editable is a lot easier than you would think. To edit an entity in realtime in sandbox mode (or your own gamemode if you have it enabled), you simply hold C (context menu) and right click on the entity. A submenu appears, and choosing properties will show a window like the one below.
The first thing to do is to mark it as editable.
The rest of the magic happens in ENT:SetupDataTables - where you're hopefully already defining your network variables for you entity. It probably looks something like this right now.
So all you need to do is add options to the end of each of these.
This might seem a bit complicated, but it's simple really.
We have a table with:
This defines the key-value name of this variable. This is the standard way in Source to handle networked entity variables, and is required for editing to work. As a bonus, it will also allow map-makers to create maps containing your entity and set these variables directly from Hammer I/O.
This is a subtable describing how to edit this variable. The actual contents of this table differs with each type of variable, and are described below.
These variables are shared between all "edit types":
title- a string - the title to show to the left of the control. If unset it will default to the control name. This must be unique to each item.
order- a number - will display the lowest orders first.
category- a string - controls are grouped by category (defaults to
readonly- a boolean initializing the contents as read only value, which can be copied, but not modified.
A simple text box.
waitforenter- boolean, whether the value should be updated in real-time as the user types, or only when they press enter. (default:
This type is a simple checkbox. There's no other settings in here apart from the shared values.
This provides the client with a number slider.
min- The minimum value (defaults to
max- The maximum value (defaults to
Identical to Float but only lets you choose integers.
This provides the client with a color selector - which is represented by a Vector. Each color component's range is between 0-1.
This is a ComboBox.
text- the default selection. (default:
values- a key/value table of available options in the ComboBox. Keys are the identifier string, values are the associated actual values. Required.
The property editors are modular, and are defined in
lua/vgui/ - each starting with
Creating your own should be quite simple by looking at these files.