-
Notifications
You must be signed in to change notification settings - Fork 603
beds: allow setting spawn point during daytime #3235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,17 +275,25 @@ function beds.on_rightclick(pos, player) | |
| local tod = minetest.get_timeofday() | ||
|
|
||
| if tod > beds.day_interval.start and tod < beds.day_interval.finish then | ||
| if beds.player[name] then | ||
| lay_down(player, nil, nil, false) | ||
| end | ||
| minetest.chat_send_player(name, S("You can only sleep at night.")) | ||
| return | ||
| end | ||
| if beds.player[name] then | ||
| lay_down(player, nil, nil, false) | ||
| end | ||
|
|
||
| -- Only set spawn if not already set to this bed | ||
| local current_spawn = beds.spawn[name] | ||
| 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 | ||
|
|
||
| minetest.chat_send_player(name, S("You can only sleep at night.")) | ||
| return | ||
| end | ||
|
||
|
|
||
| -- move to bed | ||
| if not beds.player[name] then | ||
| lay_down(player, ppos, pos) | ||
| beds.set_spawns() -- save respawn positions when entering bed | ||
| beds.set_spawns(player, pos) -- save respawn positions when entering bed | ||
| else | ||
| lay_down(player, nil, nil, false) | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,16 +50,12 @@ function beds.save_spawns() | |||||||||||||||||||||||||||||||||||
| io.close(output) | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| function beds.set_spawns() | ||||||||||||||||||||||||||||||||||||
| for name,_ in pairs(beds.player) do | ||||||||||||||||||||||||||||||||||||
| local player = minetest.get_player_by_name(name) | ||||||||||||||||||||||||||||||||||||
| local p = player:get_pos() | ||||||||||||||||||||||||||||||||||||
| -- but don't change spawn location if borrowing a bed | ||||||||||||||||||||||||||||||||||||
| if not minetest.is_protected(p, name) then | ||||||||||||||||||||||||||||||||||||
| beds.spawn[name] = p | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
| beds.save_spawns() | ||||||||||||||||||||||||||||||||||||
| function beds.set_spawns(player, bed_pos) | ||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thought here. It's not documented, thus no compat break. Lines 41 to 57 in 95991f8
|
||||||||||||||||||||||||||||||||||||
| local name = player:get_player_name() | ||||||||||||||||||||||||||||||||||||
| if not minetest.is_protected(bed_pos, name) then | ||||||||||||||||||||||||||||||||||||
| beds.spawn[name] = bed_pos | ||||||||||||||||||||||||||||||||||||
| beds.save_spawns() | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| function beds.remove_spawns_at(pos) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
elseinstead? Have the first click set the spawn point and the 2nd to notify the player that it's yet not time to sleep.