Skip to content

Commit

Permalink
util: Document functions and minor improvements
Browse files Browse the repository at this point in the history
This adds documentation to all util ffunctions.
Work towards #5

Additionally, some names in match_uuid changed.
  • Loading branch information
NeunEinser committed Mar 2, 2021
1 parent 8617e48 commit 3af131c
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
data modify storage bingo:player configurations append value {}
data modify storage bingo:player configurations[-1].name set from entity @s Item.tag.display.Name

data modify storage bingo:tmp uuid set from entity @s Thrower
data modify storage temp.bingo:input/uuid uuid set from entity @s Thrower
kill @s
execute as @a run function bingo:util/match_uuid

execute as @a[tag=bingo.uuid, limit=1] run function bingo:lobby/player_settings/save/copy_data_to_config
execute as @a[tag=bingo.uuid, limit=1] run tellraw @s {"translate": "bingo.lobby.settings.player.save.new.success", "with": [{"storage": "bingo:player", "nbt": "configurations[-1].name", "interpret": true}]}
tag @a[tag=bingo.uuid, limit=1] remove bingo.uuid
execute as @a[tag=bingo.uuid_match, limit=1] run function bingo:lobby/player_settings/save/copy_data_to_config
execute as @a[tag=bingo.uuid_match, limit=1] run tellraw @s {"translate": "bingo.lobby.settings.player.save.new.success", "with": [{"storage": "bingo:player", "nbt": "configurations[-1].name", "interpret": true}]}
tag @a[tag=bingo.uuid_match, limit=1] remove bingo.uuid_match
17 changes: 17 additions & 0 deletions data/bingo/functions/util/find_player_team.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
#> bingo:util/find_player_team
#
# Marks the current player's team in the bingo:card storage and adds the tag
# bingo.in_current_team to all teammates.
#
# This is used to be able to read or modify the current player's team's progress
# and to be able to announce reaching a goal with all members of a certain team.
#
# @internal
# @context entity Player who's team should be selected as the current team
# @output tag bingo.in_currennt_team

#>
# A member of the currently selected team.
# Used as output by bingo:util/find_player_team.
# May only be set by that function.
# @internal
#declare tag bingo.in_current_team

execute if entity @s[team=bingo.aqua] run function bingo:util/find_player_team/aqua
Expand Down
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/aqua.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/aqua
#
# Marks team aqua as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:aqua"}].selected set value true
tag @a[team=bingo.aqua] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/black.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/black
#
# Marks team aqua as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:black"}].selected set value true
tag @a[team=bingo.black] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/blue.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/blue
#
# Marks team blue as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:blue"}].selected set value true
tag @a[team=bingo.blue] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_aqua
#
# Marks team dark_aqua as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_aqua"}].selected set value true
tag @a[team=bingo.dark_aqua] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_blue
#
# Marks team dark_blue as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_blue"}].selected set value true
tag @a[team=bingo.dark_blue] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_gray
#
# Marks team dark_gray as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_gray"}].selected set value true
tag @a[team=bingo.dark_gray] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_green
#
# Marks team dark_green as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_green"}].selected set value true
tag @a[team=bingo.dark_green] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_purple
#
# Marks team dark_purple as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_purple"}].selected set value true
tag @a[team=bingo.dark_purpl] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/dark_red
#
# Marks team dark_red as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:dark_red"}].selected set value true
tag @a[team=bingo.dark_red] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/gold.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/gold
#
# Marks team gold as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:gold"}].selected set value true
tag @a[team=bingo.gold] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/gray.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/gray
#
# Marks team gray as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:gray"}].selected set value true
tag @a[team=bingo.gray] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/green.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/green
#
# Marks team green as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:green"}].selected set value true
tag @a[team=bingo.green] add bingo.in_current_team
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/light_purple
#
# Marks team light_purple as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:light_purple"}].selected set value true
tag @a[team=bingo.light_purp] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/red.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/red
#
# Marks team red as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:red"}].selected set value true
tag @a[team=bingo.red] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/white.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/white
#
# Marks team white as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:white"}].selected set value true
tag @a[team=bingo.white] add bingo.in_current_team
6 changes: 6 additions & 0 deletions data/bingo/functions/util/find_player_team/yellow.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#> bingo:util/find_player_team/yellow
#
# Marks team yellow as current team
#
# @within function bingo:util/find_player_team

data modify storage bingo:card teams[{id:"bingo:yellow"}].selected set value true
tag @a[team=bingo.yellow] add bingo.in_current_team
31 changes: 26 additions & 5 deletions data/bingo/functions/util/match_uuid.mcfunction
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#Tags @s with bingo.uuid, if @s has the same UUID as bingo:tmp
#declare tag bingo.uuid
#> bingo:util/match_uuid
#
# Tags @s with bingo.uuid if the uuid of that entity matches the input.
#
# @internal
# @input storage temp.bingo:input/uuid
# @output tag bingo.uuid_match
# @context entity Entity to check
#>
# @private
#declare score_holder $match_uuid.success

data modify storage bingo:tmp uuidCopy set from storage bingo:tmp uuid
execute store success score $success bingo.tmp run data modify storage bingo:tmp uuidCopy set from entity @s UUID
#>
# Output tag for bingo:util/match_uuid
# May only be set by this function
#
# @internal
#declare tag bingo.uuid_match
#>
# Input for bingo:util/match_uuid
# May only be read by this function
#
# @internal
#declare storage temp.bingo:input/uuid

execute if score $success bingo.tmp matches 0 run tag @s add bingo.uuid
execute store success score $match_uuid.success bingo.tmp run data modify storage temp.bingo:input/uuid uuid set from entity @s UUID

execute if score $match_uuid.success bingo.tmp matches 0 run tag @s add bingo.uuid_match

0 comments on commit 3af131c

Please sign in to comment.