Skip to content

Commit

Permalink
Card Display: Document & Better score_holder names
Browse files Browse the repository at this point in the history
This documents card display functions (Work towards #5)

score_holder name $y follows new rules for temporary score holder names
and is now called $card_display/display_card.y.
  • Loading branch information
NeunEinser committed Mar 4, 2021
1 parent 0757702 commit fca35c5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
32 changes: 27 additions & 5 deletions data/bingo/functions/card_display/display_card.mcfunction
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
#> bingo:card_display/display_card
#
# Displays the bingo card for @s
#
# @internal
# @context entity Player for displaying the card
# @reads score @s bingo.card_pos

#>
# The y coordinate of the current player
#
# @private
#declare score_holder $card_display/display_card.y

function bingo:util/find_player_team
function timer:store_current_time

scoreboard players enable @s bingo.card_pos

# text
execute store result score $y bingo.tmp run data get entity @s Pos[1]
execute store result score $card_display/display_card.y bingo.tmp run data get entity @s Pos[1]

data modify storage bingo:tmp ySpaces set value [""]
execute if score $y bingo.tmp matches 0..99 run data modify storage bingo:tmp ySpaces append value ""
execute if score $y bingo.tmp matches 0..9 run data modify storage bingo:tmp ySpaces append value ""
execute if score $y bingo.tmp matches -9..-1 run data modify storage bingo:tmp ySpaces append value ""

#Characters are \uFB26. Has to be literal character in this case. Space width 6.
execute if score $card_display/display_card.y bingo.tmp matches 0..99 run data modify storage bingo:tmp ySpaces append value ""
execute if score $card_display/display_card.y bingo.tmp matches 0..9 run data modify storage bingo:tmp ySpaces append value ""
execute if score $card_display/display_card.y bingo.tmp matches -9..-1 run data modify storage bingo:tmp ySpaces append value ""

data modify storage bingo:tmp timeSpaces set value []

#Characters are \uFB26. Has to be literal character in this case. Space width 6.
execute if score $hours timer_main matches ..99 run data modify storage bingo:tmp timeSpaces append value ""
execute if score $hours timer_main matches ..9 run data modify storage bingo:tmp timeSpaces append value ""
#Character is \uFB28. Has to be literal character in this case. Space width 8.
execute if score $hours timer_main matches 0 run data modify storage bingo:tmp timeSpaces append value ""
#Character is \uFB26. Has to be literal character in this case. Space width 6.
execute if score $hours timer_main matches 0 if score $minutes timer_main matches ..9 run data modify storage bingo:tmp timeSpaces append value ""
#Character is \uFB28. Has to be literal character in this case. Space width 8.
execute if score $hours timer_main matches 0 if score $minutes timer_main matches 0 run data modify storage bingo:tmp timeSpaces append value ""
#Character is \uFB26. Has to be literal character in this case. Space width 6.
execute if score $hours timer_main matches 0 if score $minutes timer_main matches 0 if score $seconds timer_main matches ..9 run data modify storage bingo:tmp timeSpaces append value ""

# card
execute if score @s bingo.card_pos matches ..7 run function bingo:card_display/left
execute if score @s bingo.card_pos matches 8.. run function bingo:card_display/right

title @s actionbar [{"translate":"space.46"},{"storage":"bingo:tmp","nbt":"timeSpaces","interpret":true},{"storage":"timer:display","nbt":"hh:mm:ss","interpret":true,"font":"bingo:line1_shadow","color":"black"},{"translate":"space.-47"},{"storage":"bingo:tmp","nbt":"timeSpaces","interpret":true},{"storage":"timer:display","nbt":"hh:mm:ss","interpret":true,"font":"bingo:line1"},{"translate":"space.-29"},{"storage":"bingo:tmp","nbt":"ySpaces","interpret":true},{"text":"Y: ","font":"bingo:line2_shadow","color":"black","extra":[{"score":{"objective":"bingo.tmp","name":"$y"}}]},{"translate":"space.-31"},{"storage":"bingo:tmp","nbt":"ySpaces","interpret":true},{"text":"Y: ","font":"bingo:line2","extra":[{"score":{"objective":"bingo.tmp","name":"$y"}}]},{"translate":"space.-91"},{"storage":"bingo:tmp","nbt":"cardOffset","interpret":true},{"text":"a","font":"bingo:card"},{"translate":"space.-103"},{"storage":"bingo:card","nbt":"slots[0].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[1].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[2].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[3].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[4].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[5].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[6].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[7].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[8].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[9].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[10].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[11].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[12].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[13].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[14].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[15].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[16].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[17].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[18].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[19].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[20].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[21].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[22].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[23].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[24].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.-103"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[0]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[1]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[2]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[3]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[4]","interpret":true,"font":"bingo:row0"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[5]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[6]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[7]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[8]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[9]","interpret":true,"font":"bingo:row1"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[10]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[11]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[12]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[13]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[14]","interpret":true,"font":"bingo:row2"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[15]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[16]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[17]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[18]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[19]","interpret":true,"font":"bingo:row3"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[20]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[21]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[22]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[23]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[24]","interpret":true,"font":"bingo:row4"},{"translate":"space.-105"},{"storage":"bingo:tmp", "nbt": "cardNegOffset", "interpret": true}]
title @s actionbar [{"translate":"space.46"},{"storage":"bingo:tmp","nbt":"timeSpaces","interpret":true},{"storage":"timer:display","nbt":"hh:mm:ss","interpret":true,"font":"bingo:line1_shadow","color":"black"},{"translate":"space.-47"},{"storage":"bingo:tmp","nbt":"timeSpaces","interpret":true},{"storage":"timer:display","nbt":"hh:mm:ss","interpret":true,"font":"bingo:line1"},{"translate":"space.-29"},{"storage":"bingo:tmp","nbt":"ySpaces","interpret":true},{"text":"Y: ","font":"bingo:line2_shadow","color":"black","extra":[{"score":{"objective":"bingo.tmp","name":"$card_display/display_card.y"}}]},{"translate":"space.-31"},{"storage":"bingo:tmp","nbt":"ySpaces","interpret":true},{"text":"Y: ","font":"bingo:line2","extra":[{"score":{"objective":"bingo.tmp","name":"$card_display/display_card.y"}}]},{"translate":"space.-91"},{"storage":"bingo:tmp","nbt":"cardOffset","interpret":true},{"text":"a","font":"bingo:card"},{"translate":"space.-103"},{"storage":"bingo:card","nbt":"slots[0].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[1].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[2].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[3].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[4].item.icon","interpret":true,"font":"bingo:row0"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[5].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[6].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[7].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[8].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[9].item.icon","interpret":true,"font":"bingo:row1"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[10].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[11].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[12].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[13].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[14].item.icon","interpret":true,"font":"bingo:row2"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[15].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[16].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[17].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[18].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[19].item.icon","interpret":true,"font":"bingo:row3"},{"translate":"space.-101"},{"storage":"bingo:card","nbt":"slots[20].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[21].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[22].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[23].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.4"},{"storage":"bingo:card","nbt":"slots[24].item.icon","interpret":true,"font":"bingo:row4"},{"translate":"space.-103"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[0]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[1]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[2]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[3]","interpret":true,"font":"bingo:row0"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[4]","interpret":true,"font":"bingo:row0"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[5]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[6]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[7]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[8]","interpret":true,"font":"bingo:row1"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[9]","interpret":true,"font":"bingo:row1"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[10]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[11]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[12]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[13]","interpret":true,"font":"bingo:row2"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[14]","interpret":true,"font":"bingo:row2"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[15]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[16]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[17]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[18]","interpret":true,"font":"bingo:row3"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[19]","interpret":true,"font":"bingo:row3"},{"translate":"space.-105"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[20]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[21]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[22]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[23]","interpret":true,"font":"bingo:row4"},{"storage":"bingo:card","nbt":"teams[{selected:true}].slots[24]","interpret":true,"font":"bingo:row4"},{"translate":"space.-105"},{"storage":"bingo:tmp", "nbt": "cardNegOffset", "interpret": true}]

# cleanup
data modify storage bingo:card teams[{selected: true}] set value false
Expand Down
7 changes: 7 additions & 0 deletions data/bingo/functions/card_display/left.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#> bingo:card_display/left
# Adds spaces for displaying the card on the left side, depending on preferences
#
# @within function bingo:card_display/display_card

#TODO consider different screen sizes. Currently only a width of 1920 px is supported

#next to hotbar
execute if score @s[predicate=!bingo:has_item_in_offhand] bingo.card_pos matches 0 run data merge storage bingo:tmp {cardOffset:'{"translate":"space.-195"}',cardNegOffset:'{"translate":"space.195"}'}
execute if score @s[predicate=bingo:has_item_in_offhand] bingo.card_pos matches 0 run data merge storage bingo:tmp {cardOffset:'{"translate":"space.-224"}',cardNegOffset:'{"translate":"space.224"}'}
Expand Down
8 changes: 8 additions & 0 deletions data/bingo/functions/card_display/right.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#> bingo:card_display/right
# Adds spaces for displaying the card on the right side, depending on
# preferences
#
# @within function bingo:card_display/display_card

#TODO consider different screen sizes. Currently only a width of 1920 px is supported

#next to hotbar
execute if score @s bingo.card_pos matches 8 run data merge storage bingo:tmp {cardOffset:'{"translate":"space.91"}',cardNegOffset:'{"translate":"space.-91"}'}
#next to attack indicator
Expand Down

0 comments on commit fca35c5

Please sign in to comment.