Main
Vintage Story Mods

Triggers

A trigger is a mechanism for 'learning' a draft when a certain condition is met.

The mod already has some built-in triggers, but if you want to add your own, you can use the extension method DraftsModSystem.TryLearnDraft(IPlayer player, AssetLocation draftCode).

List of built-in triggers

All built-in triggers are behaviors and are added via a list of behaviors in json.

Item triggers

Json structure:


{
	...
	"behaviors": [
		{
			"name": "TRIGGER_NAME",
			"properties": {
				"draft": "...",
				"target": {
					"type": "...",
					"code": "...",
					"allowedVariants": ["..."],
				},
			}
		}
	],
	...
}

Block triggers

Json structure:


{
	...
	"behaviors": [
		{
			"name": "TRIGGER_NAME",
			"properties": {
				"draft": "...",
				"byItem": {
					"type": "...",
					"code": "...",
					...
				},
			}
		}
	],
	...
}

Entity triggers

Json structure:


{
	...
	"behaviors": [
		{
			"code": "TRIGGER_NAME",
			"draft": "...",
			"byItem": {
				"type": "...",
				"code": "...",
				...
			},
		}
	],
	...
}

Dialogue trigger

Learns the draft when executing a trigger placed in the dialogue. Requires pomdrafts:trigger-dialogue behavior on the entity.

Json structure:


{
	components: [
		...
		{
			...
			trigger: "pomdrafts:givedraft",
			triggerdata: {
				"draft": "..."
			},
		},
		...
	]
}