#counting nights slept by player

1 messages · Page 1 of 1 (latest)

sacred anvil
#

the idea is that I deactivated insomnia and I'm making it spawn when a given player sleeps for 3 nights (ideally in a row)

execute as @a[nbt={SleepTimer:100s}] run scoreboard players add @s DaysSlept 1
execute as @e[scores={DaysSlept=3..}] at @s run summon phantom ~ ~1 ~
execute as @e[scores={DaysSlept=3..}] run scoreboard players set @s DaysSlept 0

I've got all three set as repeating, with the third command block set to conditional. I couldn't figure out how to replicate this in a datapack, tried some thing which didn't work so wanted to get some direct help.

I also noted that if a player just keeps laying in bed for example a multiplayer, the first one just keeps running and it just spams out a bajillion phantom so was wondering if this issue is possibly fixable in datapacks?

digital nymphBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

crisp lintel
#

So the easiest way to replicate this with a datapack is just to put these commands in the tick function

#

Have you made a datapack before?

#

As for fixing the issue, I would say the best way is to give the player a tag when their sleep time is 100, and then only increment their slept days score once they have the tag and their sleep time is back to 0, meaning they've slept

#

Although that might still be an issue in multiplayer, if the player gets all the way to sleep time 100 and then leaves the bed

jovial magnet
#

There is a scoreboard criteria that counts the time since a player last slept, that gets set to 0 if someone slept -> so it wouldn’t trigger multiple times, only once per sleeping player

crisp lintel
#

Oh yeah of course

digital nymphBOT
#
🗑️ Recycling Thread

This thread has been inactive for some time, so I'm going to archive it.

If you're still using the thread, just send a message and it'll pop back on the thread list.

sacred anvil
sacred anvil
#

super delayed because i got busy lmao

digital nymphBOT
#
🗑️ Recycling Thread

This thread has been inactive for some time, so I'm going to archive it.

If you're still using the thread, just send a message and it'll pop back on the thread list.