1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-11-16 15:00:18 +01:00
minetest_game/mods/beds
Auke Kok 41c2b2aeea Allow both sides of the bed to be digged up.
Tested with nodebreaker, fire.

If called from lua, minetest.remove_node() calls on_destruct() callbacks
before the map is actually updated. This means that we can't look at the
map data to determine if we're done cleaning up adjacent nodes, and we
have to stop recursing some other way.

There's no data we can pass around through functions that would survive
scope to a secondary on_destruct() callback, so we have to maintain
local state somewhere in the mod namespace.

In this case, we keep a bitflag. The bitflag is set to "true" by
default. On the first half removal, the flag is flipped and afterwards
we remove the other half node. When the on_destruct for the other half
is running, it's value is false and we flip it back to true without
removing the other half node.

This thus prevents recursing.

To facilitate easier finding of the bed partner, we tell our on_destruct
whether we're a top or bottom half node through a passed flag.

Now that the top is diggable, we just need to assure that it drops a
bottom bed part.
2016-03-18 02:35:07 +00:00
..
textures Add beds 2015-02-24 20:59:04 +01:00
api.lua Allow both sides of the bed to be digged up. 2016-03-18 02:35:07 +00:00
beds.lua Beds: Fix code style issues 2016-03-09 02:44:32 +00:00
depends.txt Add beds 2015-02-24 20:59:04 +01:00
functions.lua Beds: Fix code style issues 2016-03-09 02:44:32 +00:00
init.lua Beds: Fix code style issues 2016-03-09 02:44:32 +00:00
README.txt Rename to Minetest Game 2015-09-30 23:33:12 +01:00
spawns.lua Beds: Fix code style issues 2016-03-09 02:44:32 +00:00

Minetest Game mod: beds
=======================
by BlockMen (c) 2014-2015

Version: 1.1.1

About
~~~~~
This mod adds a bed to Minetest which allows to skip the night. To sleep rightclick the bed, if playing 
in singleplayer mode the night gets skipped imideatly. If playing on server you get shown how many other
players are in bed too. If all players are sleeping the night gets skipped aswell. Also the night skip can be forced
if more than 50% of the players are lying in bed and use this option.

Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point
is set to the beds location and you will respawn there after death.
You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf
You can also disable the night skip feature by setting "enable_bed_night_skip = false" in minetest.conf or by using
the /set command ingame.


License of source code, textures: WTFPL
---------------------------------------
(c) Copyright BlockMen (2014-2015)


This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.