Skip to main content

SelectResources

This view allows the player to select or create a resource and assign it as the value for a stat.

JSON Format

{
"type": "selectResources",
"id": ...,
"type": ...,
"margin_left": ...,
"margin_right": ...,
"margin_top": ...,
"margin_bottom": ...,
"is_visible": ...,
"validation_message": ...,
"stat": ...,
"resource_id": ...,
"view_type": ...,
"should_append": ...,
"should_save_on_selection": ...,
"create_in_place": ...,
"creation_pop_up_type": ...,
"filters": ...
}

Fields

FieldTypeRequiredDescription
idStringA unique identifier for the view. You can use it to reference view values in stat formulas by doing $view.view_id (where view_id is the id that was assigned to this view by you in the system definition)
typeRPGViewTypeThe type of this view. Note that these are all in camelCase.
margin_leftdoubleOptional. How much margin to add to the left of this view.
margin_rightdoubleOptional. How much margin to add to the right of this view.
margin_topdoubleOptional. How much margin to add to the top of this view.
margin_bottomdoubleOptional. How much margin to add to the bottom of this view.
is_visibleStatFormulaComponentOptional. A formula to specify if the view should be visible or not. Must return a bool.
validation_messageStatFormulaComponentOptional. If this view is an input, you can define this formula to return a message when the input value is invalid. If the input is valid, you should return null. Otherwise, make the formula return the string that should be shown to the user.
statStringThe path to the stat that should be linked (edited) by this view. It has to be a stat with value_type = resource, or an array of resources.
resource_idStringThe id for the resource that this view handles. This is the id of the resource in your system file, NOT the id of an instance of a resource.
view_typeSelectResourcesRPGViewTypeOptional. Defaults to list. The style with which this view should display. list will display as a button and will show the name of the resource that was selected. icon will simply display as a + icon. The icon view_type is usually used in conjunction with the should_append field and is particularly useful for resource sections.
should_appendboolOptional. Defaults to false. This property is only relevant for when the linked stat is an array of resources. When it is true, selecting a new resource will only append it to the list. This is powerful but means that, unless you provide another way to remove resources from this list (e.g: by using the ResourceSection view in conjunction with this), the player won't be able to remove resources. Having this flag be false will cause all the contents of the array to be replaced by the new selection/s.
should_save_on_selectionboolOptional. Defaults to false. Whether or not this view should automatically save as soon as a selection is made. Combine with the should_append flag and the icon view type, as well as the ResourceSection view to allow the player to add new resources to their list of resources (e.g: for a list of equipment items, spells, etc).
create_in_placeboolOptional. Defaults to false. If this flag is true, it will allow the player to create a new resource in place (by use of a pop-up) instead of having the player choose from existing resources. Note: If a non-core resource is provided in resource_id, this flag will be forced true as there's no way for a player to choose a non-core resource.
creation_pop_up_typeResourceArrayRPGViewPopUpTypesOptional. Defaults to bottomSheet. The type of pop-up that should be used when creating in place.
filtersMap<String, StatFormulaComponent>Optional. Defaults to an empty map. A map of preselected filters that should be used when allowing the player to choose their existing resource/s. The keys of the map should correspond to the stat property of existing filters (defined in the system) for that particular resource, and the values should be stat formulas that should compute to an appropriate value for that filter (e.g: if the stat is name, a string stat, then the formula should compute to a string).