My suggestion:
When writing a command in a commandblock or .mcfunction file, a ; sign (or something similar) signifies the end of the current command and allows for a new command to be written right afterwards which executes similar to chain command blocks or even better: functions, keeping the entity and location context that called the function, but instead passing the current context along to the next command.
Example:
/give @p[tag=give_item] diamond_sword
/execute at @p[tag=give_item] run playsound ... ~ ~ ~ 1 1
/execute as @p[tag=give_item] run say Received Item!
becomes ->
/execute as @p[tag=give_item] at @s run give @s diamond_sword ; playsound ... ~ ~ ~ 1 1 ; say Received Item!
Why this is useful:
The same effect can be accomplished using functions; just create a new function every time you want to execute multiple commands in the same context.
However, this can greatly inflate the amount of functions, especially when you're only running a few commands each time. But selecting the same entity each time again is inefficient and hard to read.
Similar to how coding programs encapsulate similar pieces of code in brackets (something that works well with the already implemented \ character), it would become much easier to read for experienced datapackers, not having to dive into each function. Example:
# give player the item
execute as @p[tag=give_item] at @s run \
give @s diamond_sword ; \
playsound ... ~ ~ ~ 1 1 ; \
say Received Item!
1 Comments
Please sign in to leave a comment.
Post a new comment: