diff options
Diffstat (limited to 'docs/encyclopedia_format.md')
| -rw-r--r-- | docs/encyclopedia_format.md | 84 |
1 files changed, 66 insertions, 18 deletions
diff --git a/docs/encyclopedia_format.md b/docs/encyclopedia_format.md index 5c8a7b2..01d21e5 100644 --- a/docs/encyclopedia_format.md +++ b/docs/encyclopedia_format.md @@ -21,7 +21,7 @@ All other properties are just shortcuts. ### Components "components" is the most important property. This is a list. -The items of the list are a list of 2 items: The component name (as a string) and a dict of component parameters. +The items of the list are a list of 2 items: The component name (as a string) and a dict of componentparameters. Example: @@ -64,7 +64,7 @@ The first item is the name (as string). The second item is the parameter type (as string). The optional third item is the default value. -An "args" component parameter in the component definitions will have its value filled in with the value that is given to this argument, or otherwise the default value (and if that doesn't exist either it will error). +An "args" componentparameter in the component definitions will have its value filled in with the value that is given to this argument, or otherwise the default value (and if that doesn't exist either it will error). Example: @@ -76,10 +76,64 @@ Example: "flags": ["Floor"] } -Arguments (and other component parameters) can not be used within shortcuts, so if you want to set the sprite by argument you'll have to add the Visible component manually. +Arguments (and other componentparameters) can not be used within shortcuts, so if you want to set the sprite by argument you'll have to add the Visible component manually. -### Parameter +### Save + +If the "save" property is not present in an assemblage, when construction the entity a serialize component will be added automatically unless the template specifies that it should not be saved (automatically the case for all entities added from the roomtemplate). +If this is set to false the entity is never saved. +If this is set to true the entity is always saved, even when the template says it shouldn't save. + +Everytime the map is loaded the objects from its roomtemplate will be added again, so if save is set to true for one of these objects, it will add more and more instances whenever it loads. It is best to enable this only together with the Dedup component. + +### Extract + +The default serialization for an entity is the template with which it was constructed. +For most objects this is enough, but this is not always the case. +Some objects have important properties that change during its existence. +Examples are the health of an construction, or the time when a plant should grow to the next stage. +In this case the value has to be extracted from the components in the game. That's what extract is for. + +the value of the "extract" property is a json dict where the key is the name of one of the arguments, and the value is a json list of 2 json strings. +The first is the component from which the property should be extracted. The second is the name of that property on the component (the same name that was given to it). +Not all components can have properties extracted, and some components can only have some properties extracted. + +Example: + + "builtwall": { + "arguments": [["health", "int", 100]], + "components": [ + ["Health", {"health": ["arg", "health"], "maxhealth": 100}], + ["Loot", {"loot": ["list", [{"type": "stone"}]]}] + ], + "sprite": "builtwall", + "height": 2, + "extract": {"health": ["Health", "health"]}, + "flags": ["Blocking"] + } + +## Items + +Items are things that can exist in the player inventory. +They can be dropped, and most items can be used. +Items do not have any own data, except its type. + +The "items" property in the encyclopedia is a json dict. +The keys are the names of the items. By default an assemblage of the same name will also be created. +The values are again a json dict that can have the following properties: + +- entity (template): do not automatically create an assemblage when the item is dropped, but use this template instead for the dropped item. +- sprite (string): the sprite of the assemblage that is created when the item is dropped. Defaults to the key of the entry +- name (string): name of the item. Defaults to the key of the entry. +- action: the action that will be executed when using the item. The value of this is a list of two items: the action type and the argument. There are the following action types: + - eat (argument is an int): Remove the item from inventory, and add argument to the current health, + - build (argument is a list of 3 elements: first a template, second and third a list of flags (as strings)): Remove the item from the inventory, and build the template from its first argument at the current location. This is only possible if all the flags from the second argument are on the current tile, and none of the flags in the third argument. + - equip (argument is a list of 2 elements: a string and a dict of numbers): the item is marked as equipped. If another equipped item is equipped and has the same slot (first argument) as this item, the other item will be unequipped. The second argument holds the stat improvements. + +# Used concepts + +## Parameter A parameter can be a string, an integer, a float, a boolean, a list, a pos, a template or an interaction. The specific type can be given explicitly by giving a list of 2 elements: the first is the type (as string), the second the actual value. For example: `["int", 3]`. @@ -91,24 +145,18 @@ Interactions (which also alway need type annotation) are a json list of 2 values The type of the argument value can differ based on the interaction type. todo: list interaction types with description what they do and their arguments. -### ComponentParameter +## ComponentParameter -A component parameter is either a parameter, or a special function. +A componentparameter is either a parameter, or a special function. The special functions are given in the same way as the type annotations of a parameter, so as a pair of the type of function (as string) and its argument. -The only place where component parameters currently occur is as parameters to components. +The only place where componentparameters currently occur is as parameters to components. -Possible component parameters: +Possible componentparameters: -- arg (argument: string): take the actual value from the assemblage argument that is named by the argument of this component parameter -- random (argument: list of component parameters): pick a random value from its arguments. All argument items must have the same type. -- concat (argument: list of component parameters): concatenate the string value of its arguments. All argument items must be of type string. -- if (argument: list of 3 component parameters: condition, thenpart, elsepart) if the condition evaluates to true, take the value of thenpart, otherwise take the value of elsepart. The condition must be of type bool, and the thenpart and elsepart must have the same type. +- arg (argument: string): take the actual value from the assemblage argument that is named by the argument of this componentparameter +- random (argument: list of componentparameters): pick a random value from its arguments. All argument items must have the same type. +- concat (argument: list of componentparameters): concatenate the string value of its arguments. All argument items must be of type string. +- if (argument: list of 3 componentparameters: condition, thenpart, elsepart) if the condition evaluates to true, take the value of thenpart, otherwise take the value of elsepart. The condition must be of type bool, and the thenpart and elsepart must have the same type. - self (does not use its argument): the template given to the assemblage used to construct this pre-entity. - name (does not use its argument): the name of the assemblage in the encyclopedia. -### Save - -If the "save" property is not present in an assemblage, when construction the entity a serialize component will be added automatically unless the template specifies that it should not be saved (automatically the case for all entities added from the map file). -If this is set to false the entity is never saved. -If this is set to true the entity is always saved, even when the template says it shouldn't save. - |
