-
-
Notifications
You must be signed in to change notification settings - Fork 14
FGD Generation
By enabling the GodotVMF - FGD Generator plugin, you'll be able to generate FGD files based on your implemented entities. To make the entities appear in the FGD, you need to define the @entity marker with the entity type in the script. You can specify how your entity will look in Hammer via ## @appearance <appearance_value>; there can be more than one @appearance.
@tool
## @entity SolidClass
## @base Targetname, Origin, Angles
## @appearance iconsprite("editor/info_target.vmt")
## Description of the entity
class_name func_some_entity
extends VMFEntityNode
# SolidClass means it's a brush entity
# PointClass means it's a point entityYou can find all entity classes here. Appearance options can be found below.
Important
Don't leave an empty line between the class/property/method definition and the markers themselves; otherwise, they won't be shown in the FGD file.
All constants starting with the prefix FLAG_ will be identified as flags.
# func_some_entity.gd
const FLAG_START_DISABLED = 1
const FLAG_SOME_FLAG = 2
const FLAG_ANOTHER_ONE = 4Properties marked with ## @exposed will be exposed in the FGD file with the specified types.
# func_some_entity.gd
# Will be presented in the FGD as "integer". Description should begin after `@exposed` mark
## @exposed
## Description (comments started with ##) of the property will be moved into the FGD as well.
var property_1: int = 10;
# Will be presented in the FGD as "float"
## @exposed
var property_2: float = 10.0;
# Will be presented in the FGD as target_destination
# Adding
## @exposed
var property_3: Node:
get: return get_target(entity.get("property_3", ""));
# Will be presented in the FGD as choices with 0 and 1 values
## @exposed
var property_4: bool;
enum ChoicesExample {
VALUE_1,
VALUE_2,
VALUE_3,
}
# Will be presented in the FGD as choices with the values above
## @exposed
var property_5: ChoicesExample = ChoicesExample.VALUE_1;Also, you can change the property name in the FGD file by adding a value to @exposed:
## @exposed Custom Name
var property_5: float = 1.0;You can specify a specific type for the exposed property via @type. In this example, the property model_path will be presented as a field for a model:
## @type studio
var model_path: String:
get: return entity.get("model_path", "");More about FGD types here
Signals will be presented as outputs
# func_some_entity.gd
@warning_ignore_start("unused_signal")
signal OnBreak()
signal OnStartTouch()
@warning_ignore_restore("unused_signal")Methods named in PascalCase or marked with ## @exposed will be identified as inputs.
# func_some_entity.gd
# Argument started with "_" will be identified as "void"
func Enable(_param): pass;
func Disable(_param): pass;
func Toggle(_param): pass;
# If target_destination defined then in the value field in hammer will be an entity selector
## @exposed
func remove_entity(target_destination): pass; # Will be represented as RemoveEntity(target_destination)Once you have defined everything you need in your entity, the FGD file (named after the project name) will be automatically created in the project root:
@SolidClass base(Targetname, Origin, Angles) iconsprite("editor/info_target.vmt") = func_some_entity: "Description of the entity" [
spawnflags(Flags) = [
1 : "Start Disabled" : 0
2 : "Some Flag" : 0
4 : "Another One" : 0
]
property_1(integer) : "Property 1" : "10" : "Description (comments started with ##) of the property will be moved into the FGD as well"
property_2(float) : "Property 2" : "10.0" : ""
property_3(target_destination) : "Property 3" : "100.0" : ""
property_4(choices) : "Property 4" : 0 = [
0 : "No"
1 : "Yes"
]
property_5(choices) : "Property 5" : 0 = [
0 : "Value 1"
1 : "Value 2"
2 : "Value 3"
]
output OnBreak(void) : ""
output OnStartTouch(void) : ""
input Enable(void) : ""
input Disable(void) : ""
input Toggle(void) : ""
input RemoveEntity(target_destination) : ""
]