Skip to content

beds: allow setting spawn point during daytime#3235

Open
GP-commits wants to merge 4 commits intoluanti-org:masterfrom
GP-commits:daytime-spawnpoint
Open

beds: allow setting spawn point during daytime#3235
GP-commits wants to merge 4 commits intoluanti-org:masterfrom
GP-commits:daytime-spawnpoint

Conversation

@GP-commits
Copy link

Summary

Allow players to set their spawn point by right-clicking a bed during daytime.

Changes

  • Set spawn point on right-click even during daytime
  • Kept existing night sleep behavior unchanged

Motivation

Improves convenience without affecting existing mechanics.

Closes #3151

@sfan5 sfan5 added the Feature label Mar 23, 2026
@GP-commits
Copy link
Author

Hi, the workflows are awaiting approval. Could you please approve them so checks can run?

@ssdaniel24
Copy link
Contributor

Seems like if i will spam clicking on bed at the day, it will write in the chat:

You can only sleep at night.
Spawn point set.
You can only sleep at night.
Spawn point set.
You can only sleep at night.
Spawn point set.
...

I think you should add check for already set spawnpoint.

@GP-commits
Copy link
Author

Good catch, thanks! I’ll add a check to prevent repeated spawn setting.


minetest.chat_send_player(name, S("You can only sleep at night."))
return
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent the entire new code block so that it makes sense again.

if not current_spawn or vector.distance(current_spawn, pos) > 0.1 then
beds.set_spawns(player, pos)
minetest.chat_send_player(name, S("Spawn point set."))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about else instead? Have the first click set the spawn point and the 2nd to notify the player that it's yet not time to sleep.

@SmallJoker
Copy link
Member

SmallJoker commented Mar 24, 2026

Hi, the workflows are awaiting approval.

FYI, running the checks locally is straight-forward. Install luacheck and give it the path to minetest_game to parse. Interestingly it does not catch indent (stylistic) issues.

end
end
beds.save_spawns()
function beds.set_spawns(player, bed_pos)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a documented API function? if so, won't this break compatibility?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thought here. It's not documented, thus no compat break.

Beds API
--------
beds.register_bed(
"beds:bed", -- Bed name
def -- See [#Bed definition]
)
* `beds.can_dig(bed_pos)` Returns a boolean whether the bed at `bed_pos` may be dug
* `beds.read_spawns() ` Returns a table containing players respawn positions
* `beds.kick_players()` Forces all players to leave bed
* `beds.kick_player_at(pos)` Forces player out of bed at pos (returns true on success, false otherwise)
* `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping
* `beds.day_interval` Is a table with keys "start" and "finish". Allows you
to set the period of the day (timeofday format). Default: `{ start = 0.2, finish = 0.805 }`.
### Bed definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Beds: set spawn point at daytime

4 participants