To preface the question, I'll state I'm attempting to build an in-game clock. One that tracks seconds, minutes, hours, etc. I use a fake player in the scoreboard, and I give them the following scores - clock_ticks, clock_seconds, clock_minutes, clock_hours etc. If this were normal scripting, I'd just make a check for ticks at or above 20 and then increment seconds (and so on, for seconds and minutes, minutes and hours, etc) with if/then statements.
The 'if' component of the function command sort of mimics if/then statements, however I'm not sure how to check for a fake player's score. So I'm wondering if anyone has any ideas how to work around this. To note, I'm trying to avoid using an armor stand or the like. I'd prefer to have a system that doesn't require in-game components/entities to run.
** Edit
I came up with a solution for the clock. I've posted it to PasteBin. Have a look at it, if you'd like. Let me know if you can come up with a more elegant solution. This seems pretty heavy for tracking time.
I still have the issue where I'd like to be able to test for fake_player's scores and run commands based on it. Without having to target an entity like an armor stand, that is.
The Meaning of Life, the Universe, and Everything.
Join Date:
1/26/2018
Posts:
48
Member Details
I'm not sure if functions currently allow tracking of fake players, to be honest.
Perhaps I'm wrong, and I'm assuming it will change. Have you tried using a selector instead? *MAYBE* it would work? As a side note, have you created the fake player already? (Just making sure!)
In the case of your PasteBin, may I ask why there is so much multiplying dividing, etc?
To be honest, I would just use selector arguments. Something like:
@Robified - As of 1.13, the execute command has selectors built in that can target fake players. So you run the execute command on a fake player, then run functions based on that.
ex. - execute if score fake_player some_score matches 37 run function custom:my_function
The Meaning of Life, the Universe, and Everything.
Join Date:
1/26/2018
Posts:
48
Member Details
If it's not working for you, it may be a bug. I haven't gotten around to recoding my commands that rely on a fake player, so I haven't tested any of it yet haha.
To preface the question, I'll state I'm attempting to build an in-game clock. One that tracks seconds, minutes, hours, etc. I use a fake player in the scoreboard, and I give them the following scores - clock_ticks, clock_seconds, clock_minutes, clock_hours etc. If this were normal scripting, I'd just make a check for ticks at or above 20 and then increment seconds (and so on, for seconds and minutes, minutes and hours, etc) with if/then statements.
The 'if' component of the function command sort of mimics if/then statements, however I'm not sure how to check for a fake player's score. So I'm wondering if anyone has any ideas how to work around this. To note, I'm trying to avoid using an armor stand or the like. I'd prefer to have a system that doesn't require in-game components/entities to run.
** Edit
I came up with a solution for the clock. I've posted it to PasteBin. Have a look at it, if you'd like. Let me know if you can come up with a more elegant solution. This seems pretty heavy for tracking time.
I still have the issue where I'd like to be able to test for fake_player's scores and run commands based on it. Without having to target an entity like an armor stand, that is.
I'm not sure if functions currently allow tracking of fake players, to be honest.
Perhaps I'm wrong, and I'm assuming it will change. Have you tried using a selector instead? *MAYBE* it would work? As a side note, have you created the fake player already? (Just making sure!)
In the case of your PasteBin, may I ask why there is so much multiplying dividing, etc?
To be honest, I would just use selector arguments. Something like:
scoreboard players add @a[name=fake_player] clock_tick 1
scoreboard players add @a[name=fake_player,score_clock_tick=20] clock_sec 1
scoreboard players set @a[name=fake_player,score_clock_tick=20] clock_tick 0
scoreboard players add @a[name=fake_player,score_clock_sec=60] clock_minute 1
scoreboard players set @a[name=fake_player,score_clock_sec=60] clock_sec 0
scoreboard players add @a[name=fake_player,score_clock_minute=60] clock_hour 1
scoreboard players set @a[name=fake_player,score_clock_minute=60] clock_minute 0
scoreboard players add @a[name=fake_player,score_clock_hour=24] clock_day 1
scoreboard players set @a[name=fake_player,score_clock_hour=24] clock_hour 0
scoreboard players add @a[name=fake_player,score_clock_day=365] clock_year 1
scoreboard players set @a[name=fake_player,score_clock_day=365] clock_day 0
That would handle it fairly well, and cut down on the number of commands.
@Robified - As of 1.13, the execute command has selectors built in that can target fake players. So you run the execute command on a fake player, then run functions based on that.
ex. - execute if score fake_player some_score matches 37 run function custom:my_function
If it's not working for you, it may be a bug. I haven't gotten around to recoding my commands that rely on a fake player, so I haven't tested any of it yet haha.
It works. Doesn't help me with my Realms server right now, but 1.13 isn't too far around the corner, so I'm just getting ahead and ready for that.