Skip to content

Commit

Permalink
release(0.5.3): add filter and resolve to the string module
Browse files Browse the repository at this point in the history
  • Loading branch information
moxvallix committed Jan 31, 2023
1 parent b8eee6d commit e2a6823
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.3] - 2023-02-01
### Added
- String / Filter, returns true if the given string is not in the target array.
- String / Resolve, returns the given JSON text string resolved as the executing entity.

## [0.5.2] - 2023-01-30
### Added
- Predicates to detect a player sneaking, swimming, sprinting, or on fire.
Expand Down
8 changes: 8 additions & 0 deletions data/moxlib/functions/api/string/filter.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Entity: a96aef33-7240-467a-94f0-bc73535ced07
summon marker ~ ~ ~ {UUID:[I;-1452609741,1916814970,-1796162445,1398598919]}

data modify entity a96aef33-7240-467a-94f0-bc73535ced07 Tags set from storage moxlib:api/string/filter target
data modify entity a96aef33-7240-467a-94f0-bc73535ced07 Tags append from storage moxlib:api/string/filter key

execute store success storage moxlib:api/string/filter output byte 1 run data modify entity a96aef33-7240-467a-94f0-bc73535ced07 Tags set from storage moxlib:api/string/filter target
kill a96aef33-7240-467a-94f0-bc73535ced07
7 changes: 7 additions & 0 deletions data/moxlib/functions/api/string/resolve.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Entity: babd0a7e-aa21-473b-a065-1495066cb515
summon armor_stand ~ ~ ~ {UUID:[I;-1162016130,-1440659653,-1603988331,107787541],HandItems:[{id:"minecraft:debug_stick",Count:1b}],Marker:1b,Invisible:1b}

execute as @s run item modify entity babd0a7e-aa21-473b-a065-1495066cb515 weapon.mainhand moxlib:string/resolve
data modify storage moxlib:api/string/resolve output set from entity babd0a7e-aa21-473b-a065-1495066cb515 HandItems[0].tag.display.Name

kill babd0a7e-aa21-473b-a065-1495066cb515
9 changes: 9 additions & 0 deletions data/moxlib/item_modifiers/string/resolve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"function": "minecraft:set_name",
"entity": "this",
"name": {
"nbt": "target",
"storage": "moxlib:api/string/resolve",
"interpret": true
}
}
35 changes: 35 additions & 0 deletions docs/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ Example:
}
```

### Filter
Returns false if the given key is within the given target string array, otherwise true.

**Function:** `moxlib:api/string/filter`
**Expects:**
- `target` -- an array of strings
- `key` -- a string to compare with

**Returns:**
- `output` -- true if the string is not in target, false if it is.

Example:
```
/data modify storage moxlib:api/string/filter target set value ["a","b","c"]
/data modify storage moxlib:api/string/filter key set value "d"
/function moxlib:api/string/filter
/data get storage moxlib:api/string/filter
---
{
output: true
}
```

### Resolve
Resolves the given JSON text string, as the executing entity.

**Function:** `moxlib:api/string/resolve`
**Expects:**
- `target` -- a JSON text string

**Returns:**
- `output` -- resolved JSON text string


### Reset
Resets the lock, in the unlikely case it gets stuck.

Expand Down

0 comments on commit e2a6823

Please sign in to comment.