Skip to content

Commit

Permalink
Timer: Move internal scores to new objective and document them
Browse files Browse the repository at this point in the history
This moves internal scores used by the timer from 91.timer.main to
91.timer.intern.

The sole constant (value 60) was also moved from 91.timer.const to the
new objective, and the const objective was removed.

All internal score holders are also properly documented now (Work
towards #5)
  • Loading branch information
NeunEinser committed Mar 6, 2021
1 parent c85c5f6 commit c8635d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 18 additions & 3 deletions data/neun_einser.timer/functions/internal/init.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,29 @@ scoreboard objectives add 91.timer.main dummy
#declare score_holder $hours

#>
# This scoreboard is used to store constant values.
# Internal scoreboard for non-temporary memory
#
# @internal
scoreboard objectives add 91.timer.const dummy
scoreboard objectives add 91.timer.intern dummy

#>
# @internal
#declare score_holder 60
scoreboard players set 60 91.timer.const 60
scoreboard players set 60 91.timer.intern 60

#>
# Raw time the world border was started at. The world border is reset once it
# reaches a certain threshold to prevent it running out of blocks.
# @internal
#declare score_holder $start
#>
# Blocks the world border travels per second. Used for some internal
# calculations.
#
# For example, if this was started with neun_einser.timer:start/millis, this
# will be 1000.
#
# @internal
#declare score_holder $blocks_per_second

data merge storage neun_einser.timer:display {"hh:mm:ss.s": '[{"storage": "neun_einser.timer:display", "nbt": "internal.hours", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.minutes", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.seconds", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.millis", "interpret": true}]', "hh:mm:ss": '[{"storage": "neun_einser.timer:display", "nbt": "internal.hours", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.minutes", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.seconds", "interpret": true}]', "hh:mm": '[{"storage": "neun_einser.timer:display", "nbt": "internal.hours", "interpret": true}, {"storage": "neun_einser.timer:display", "nbt": "internal.minutes", "interpret": true}]'}
8 changes: 4 additions & 4 deletions data/neun_einser.timer/functions/read.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ scoreboard players operation $millis 91.timer.main = $raw 91.timer.main
scoreboard players operation $seconds 91.timer.main = $millis 91.timer.main
scoreboard players operation $seconds 91.timer.main /= $blocks_per_second 91.timer.main
scoreboard players operation $minutes 91.timer.main = $seconds 91.timer.main
scoreboard players operation $minutes 91.timer.main /= 60 91.timer.const
scoreboard players operation $minutes 91.timer.main /= 60 91.timer.intern
scoreboard players operation $hours 91.timer.main = $minutes 91.timer.main
scoreboard players operation $hours 91.timer.main /= 60 91.timer.const
scoreboard players operation $hours 91.timer.main /= 60 91.timer.intern

scoreboard players operation $millis 91.timer.main %= $blocks_per_second 91.timer.main
scoreboard players operation $seconds 91.timer.main %= 60 91.timer.const
scoreboard players operation $minutes 91.timer.main %= 60 91.timer.const
scoreboard players operation $seconds 91.timer.main %= 60 91.timer.intern
scoreboard players operation $minutes 91.timer.main %= 60 91.timer.intern

0 comments on commit c8635d8

Please sign in to comment.