FGD Generation - H2xDev/GodotVMF GitHub Wiki

By turning on plugin GodotVMF - FGD Generator you'll be able to generate FGD files based on your implemented entities. To get the implemented appeared in the FGD you need to define @entity marker with entity type in the script. You can specify how your entity will look in Hammer via ## @appearance <appearance_value>, there might 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 ValveIONode

# SolidClass means it's a brush entity
# PointClass means it's a point entity

All entity classes you can find here. Options for appearance can be found below.

[!IMPORTANT] Don't leave an empty line between class/property/method definition and the markers itself otherwise they won't shown in the FGD file

Flags

All constants started with 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 = 4

Properties

Properties that have ## @exposed will be exposed into the FGD file with 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;

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 specific type for the exposed property via @type. In this example the property model_path will be presented as field for model:

## @type studio
var model_path: String:
  get: return entity.get("model_path", "");

More about FGD types here

Outputs

Signals will be presented as outputs

# func_some_entity.gd
@warning_ignore_start("unused_signal")

signal OnBreak()
signal OnStartTouch()

@warning_ignore_restore("unused_signal")

Inputs

Methods named in PascalCase or has ## @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)

Conclusion

Once you defined everything you need in your entity the FGD file named as the project name will be automatically created in the root of the project:

@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"
        ]

	output OnBreak(void) : ""
	output OnStartTouch(void) : ""

	input Enable(void) : ""
	input Disable(void) : ""
	input Toggle(void) : ""
	input RemoveEntity(target_destination) : ""
]