-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
5,758 additions
and
1,465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# DDAPI Config Types | ||
|
||
## Object | ||
|
||
Objects are defined within `hammerstone/objects/*.json`. | ||
|
||
Schema: `"$schema": "https://raw.githubusercontent.com/Sapiens-OSS/hammerstone-schemas/main/schemas/object.schema.json"` | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"hammerstone:object_definition": { | ||
"description": { | ||
"identifier": "apple" | ||
}, | ||
"components": { | ||
... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Storage | ||
|
||
Storages are defined within `hammerstone/storage/*.json` | ||
|
||
Schema: | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"hammerstone:storage_definition": { | ||
"description": { | ||
"identifier": "apple_storage" | ||
}, | ||
"components": { | ||
... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Shared Config | ||
|
||
Shared configs are files that define lots of small definitions. You can split them into multiple files, or combine them. | ||
|
||
Shared configs are defined within `hammerstone/shared/*.json` | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"hammerstone:global_definitions": { | ||
"hs_seat_types": [ | ||
... | ||
], | ||
"hs_model_remaps": [ | ||
... | ||
], | ||
"hs_materials": [ | ||
... | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## Builders | ||
|
||
Builders are lua-only files defined in `hammerstone/builders/*.lua`. They are explained further in [lua builders.](./ddapi-lua-builders.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Lua Builders | ||
|
||
Builders are a hybrid approach between normal modding, and config driven modding. Instead of defining each config in it's own file, builders allow you to create lots of definitions at once, all from a single file. This is possible via defining a Lua module that defines an "interface" of functions. Hammerstone will call these functions automatically, and interpret the list of results as objects to create via Hammerstone. Builders are useful when you want to generate lots of similar objects, or need more programatic control. | ||
|
||
## Define a Builder | ||
|
||
`builders` are defined inside of `hammerstone/builders/*.lua`. Unlike all other config files, they MUST be defined in lua -not json. | ||
|
||
## Format of a Builder | ||
|
||
The base file will look something like this: | ||
|
||
```lua | ||
local gen = {} | ||
return gen | ||
``` | ||
|
||
In other words, its a totally normal module. The trick is you need to define some (optional) functions. These are: | ||
|
||
- `getObjectConfigs()` | ||
- `getMaterials()` | ||
- `getModelRemaps()` | ||
- `getResourceGroups()` | ||
|
||
The return result should be a list of valid ddapi configs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Lua Configs | ||
|
||
Often, when writing Hammerstone DDAPI mods, you might find the json-based API limiting, or annoying to use. In that case, use lua! You can write 1:1 the same configs, except just do it in lua instead. | ||
|
||
Example (truncated): | ||
|
||
```lua | ||
local data = mjrequire "furniture/data" | ||
|
||
return { | ||
description = { | ||
identifier = "chair" | ||
}, | ||
components = { | ||
hs_object = { | ||
model = "chair" | ||
}, | ||
hs_buildable = { | ||
skill = "woodBuilding", | ||
build_sequence = "clearObjectsAndTerrainSequence", | ||
... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Why Lua? | ||
|
||
One of the biggest reasons to use Lua is to use the [lua builder](./ddapi-lua-builders.md) format to generate lots of actors programatically. There are other reasons though as well, such as a preference for the syntax, or inline calculations. | ||
|
||
## Props | ||
|
||
When using Lua, the `props` field can be used to define some lua data that will be 1:1 copied to the base game object. For example, imagine you're creating an object in which `preventShiftOnTerrainSurfaceModification` MUST be true. This isn't something we bothered to add to the DDAPI yet, so by default, you're blocked. | ||
|
||
`props` is the safety hatch. Simple define it like this: | ||
|
||
```lua | ||
hs_object = { | ||
model = "chair", | ||
props = { | ||
preventShiftOnTerrainSurfaceModification = true | ||
} | ||
}, | ||
``` | ||
|
||
The results of the `props` will be moved into the object when it's created. | ||
|
||
`props` is allowed in other places as well. For example, when defined inside of the `hs_evolving_object`, the `props` field will move that lua code into the evolving object definition. Same for resources, storage, craftables, etc. | ||
|
||
If you're ever perusing a long list of objects in the base game code (e.g., `gameObject.lua`), and see a field you want to insert into your config, add it via `props` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.