Skip to content

Commit

Permalink
Doc/Schema: add access_resolver documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Dec 31, 2023
1 parent 37d39cb commit 965c294
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/PACKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ Locations define drops on maps, rules to have them accessible as well as the loo
{
"name": "Area name",
"short_name": "Area", // shorter version of name. currently unused
"access_resolver": "$func", // optional method to resolve access. overrides access_rules
"access_rules": [
"<rule1>,<rule2>",
"<rule3>,<rule4>",
Expand Down Expand Up @@ -399,6 +400,11 @@ Locations define drops on maps, rules to have them accessible as well as the loo
Each `map_location` is a square on the map and shows a popup with individual chests.

**Rules:**
If access_resolver if provided or inherited for a section and starts with `$`, access_rules are ignored and the
provided global Lua function is called for each section instead of resolving access_rules. Useful for pure Lua logic.
The Lua function has to return one of AccessibilityLevel values.
If access_resolver is `""` (default), access_rules are resolved internally as described below.

Rules starting with `$` will call the lua function with that name, `@<location>/<section>` will use the result of a different access rule, other rules will just look at items' `code` (runs ProviderCountForCode(rule)).

For `$` rules, arguments can be supplied with `|`. `$test|a|b` will call `test("a","b")`.
Expand Down
8 changes: 8 additions & 0 deletions schema/packs/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"description": "Short version of name. Currently unused.",
"type": "string"
},
"access_resolver": {
"description": "Optional method to resolve access. Use \"$func\" to call a Lua function with Section as argument that returns an AccessibilityLevel.",
"type": "string"
},
"access_rules": {
"example": [
"rule1,rule2",
Expand Down Expand Up @@ -146,6 +150,10 @@
"description": "Short version of name. Currently unused.",
"type": "string"
},
"access_resolver": {
"description": "Optional method to resolve access for each section. Use \"$func\" to call a Lua function with Section as argument that returns an AccessibilityLevel. This value is inherited by children, empty string resets to default behavior.",
"type": "string"
},
"access_rules": {
"example": [
"rule1,rule2",
Expand Down
8 changes: 8 additions & 0 deletions schema/packs/strict/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"description": "Short version of name. Currently unused.",
"type": "string"
},
"access_resolver": {
"description": "Optional method to resolve access. Use \"$func\" to call a Lua function with Section as argument that returns an AccessibilityLevel.",
"type": "string"
},
"access_rules": {
"example": [
"rule1,rule2",
Expand Down Expand Up @@ -128,6 +132,10 @@
"description": "Short version of name. Currently unused.",
"type": "string"
},
"access_resolver": {
"description": "Optional method to resolve access for each section. Use \"$func\" to call a Lua function with Section as argument that returns an AccessibilityLevel. This value is inherited by children, empty string resets to default behavior.",
"type": "string"
},
"access_rules": {
"example": [
"rule1,rule2",
Expand Down

0 comments on commit 965c294

Please sign in to comment.