Allow apps to specify mod version requirements (#798)
* Allow apps to specify mod version requirements
* Allow a function in requires field and move to `readConfig()`
* Add `server_mods` to system_info()
* Add prefixes and default to `=`
* Added docs for `requires` and for `system_info('server_mods')`
* Better docs for requires (mention * and available prefixes)
* Update docs/scarpet/api/Overview.md
* Update docs/scarpet/api/Overview.md
* Update docs/scarpet/api/Overview.md
Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
This commit is contained in:
1 parent
0e84ef5d65
commit
b7b7667484
5 files changed
+135
-2
No files matched your search
@@ -56,6 +56,30 @@ conflicts and ambiguities between different paths of execution. While ambiguous
|
||||
and they tend to execute correctly, the suggestion support works really poorly in these situations and scarpet
|
||||
will warn and prevent such apps from loading with an error message. If `allow_command_conflicts` is specified and
|
||||
`true`, then scarpet will load all provided commands regardless.
|
||||
* `'requires'` - defines either a map of mod dependencies in Fabric's mod.json style, or a function to be executed. If it's a map, it will only
|
||||
allow the app to load if all of the mods specified in the map meet the version criteria. If it's a function, it will prevent the app from
|
||||
loading if the function does not execute to `false`, displaying whatever is returned to the user.
|
||||
|
||||
Available prefixes for the version comparison are `>=`, `<=`, `>`, `<`, `~`, `^` and `=` (default if none specified), based in the spec
|
||||
at [NPM docs about SemVer ranges](https://docs.npmjs.com/cli/v6/using-npm/semver#ranges)
|
||||
```
|
||||
__config() -> {
|
||||
'requires' -> {
|
||||
'carpet' -> '>=1.4.33', // Will require Carpet with a version >= 1.4.32
|
||||
'minecraft' -> '>=1.16', // Will require Minecraft with a version >= 1.16
|
||||
'chat-up' -> '*' // Will require any version of the chat-up mod
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
__config() -> {
|
||||
'requires' -> _() -> (
|
||||
d = convert_date(unix_time());
|
||||
if(d:6 == 5 && d:2 == 13,
|
||||
'Its Friday, 13th' // Will throw this if Friday 13th, will load else since `if` function returns `null` by default
|
||||
)
|
||||
}
|
||||
```
|
||||
* `'command_permission'` - indicates a custom permission to run the command. It can either be a number indicating
|
||||
permission level (from 1 to 4) or a string value, one of: `'all'` (default), `'ops'` (default opped player with permission level of 2),
|
||||
`'server'` - command accessible only through the server console and commandblocks, but not in chat, `'players'` - opposite
|
||||
@@ -286,4 +310,4 @@ if a player is in the other dimension, calls to entities and blocks around that
|
||||
Moreover, running commandblocks in the spawn chunks would mean that commands will always refer to the overworld
|
||||
blocks and entities. In case you would want to run commands across all dimensions, just run three of them,
|
||||
using `/execute in overworld/the_nether/the_end run script run ...` and query players using `player('*')`,
|
||||
which only returns players in current dimension, or use `in_dimension(expr)` function.
|
||||
which only returns players in current dimension, or use `in_dimension(expr)` function.
|
||||
Reference in new issue
Block a user