I have a setup where a command block is attached to a daylight sensor. Every time it's night it expands the world border by 1. I want to make it so that each day increases more. For example, first day it expands one block. Second day it expands two and so on. This can be achieved by adding 1 to a variable and using that data to change the worldborder. Since variables don't exist, can anyone suggest another method to do so? Thanks.
The first issue is detecting when to change the world border. This can be done with either a daylight detector or a scoreboard that counts to 24000 and then resets.
Either way, whenever you detect a new day, add 1 to a scoreboard score
expandToday. Copy its value into another score
toExpand. Then, decrement
toExpand until it is 0 while executing
/worldborder add 1 0.
Finally found the time to make and test something; I hope it's not too late. As @BunnyMerz suggested, counting isn't reliable and
/time query ... should be used. There might be room for improvements, but it works for now.
- Setup (run once)
scoreboard objectives add wbdata dummy scoreboard players set time wbdata 0 scoreboard players set toexpand wbdata 0 scoreboard players set exptoday wbdata 1 scoreboard players set ZERO wbdata 0
For the following, let REP = repeating, CHN = chain, UNC = unconditional and CON = conditional. All command blocks are set to Always Active.
- Chain 1: REP|UNC
execute store result score time wbdata run time query daytime
- Chain 2: REP|UNC -> CHN|CON
execute if score time wbdata matches 10 run scoreboard players operation toexpand wbdata = exptoday wbdata scoreboard players add exptoday wbdata 1
- Chain 3: REP|UNC -> CHN|CON
execute if score toexpand wbdata >= ZERO wbdata run scoreboard players remove toexpand wbdata 1 worldborder add 1