What is "this" data?
The "this" data is an entity data from the entity that runs a function. So for example, if a player named "Steve" run a function, then the "this" data of that function would be the entity data of "Steve".
The "this" data may be modified by "execute as ..." when using that command to run a function.
Why do you need "this" data in function macro?
Such feature like that would be really useful for saving and processing custom storage data related to "this" itself.
For example, lets define "this" data macro syntax like this:
$(#this.<path>)
With that syntax, we can save, process and use custom storage data that are related to "this":
# Example Warp Datapack
# [warp:set]
$data modify storage warp:data WarpList append value {OwnerUUID: $(#this.UUID), Name: $(Name), Pos: $(#this.Pos)}
# [warp:goto]
$function warp:goto.action with storage warp:data WarpList[{OwnerUUID: $(#this.UUID), Name: $(Name)}]
# [warp:goto.action]
$tp $(Pos[0]) $(Pos[1]) $(Pos[2])
# [How to use]
# set warp with name "my home warp"
function warp:set {Name: "my home warp"}
# somewhere in wilderness
function warp:goto {Name: "my home warp"}
Example of "execute as" modifying "this" data:
# [example:say_test]
execute as @e run function example:say_test.action
# [example:say_test.action]
$say $(#this.Health)
# ^ this executed on @e, would say entities' health point
This proposal would also require supporting path/accessing nested object in function macro:
# argument data: {a: [3, 7], b: {a: 2}}
$say $(a[1]) - $(b.a)
# "7 - 2"Please sign in to leave a comment.
0 Comments