From ac5e8176b9a2b36520bcc78b9d486aea7742d554 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 22 May 2022 14:28:24 +0000 Subject: Add relative numbers for commands by prepending ~ (#9588) * Add relative numbers for commands by prepending ~ * Some builtin code cleanup * Disallow nan and inf in minetest.string_to_area * Remove unused local variable teleportee (makes Luacheck happy) * Clean up core.string_to_pos * Make area parsing less permissive * Rewrite tests as busted tests * /time: Fix negative minutes not working Co-authored-by: Lars Mueller --- doc/lua_api.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 6046a5902..96b1cc469 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -3550,8 +3550,16 @@ Helper functions * `minetest.string_to_pos(string)`: returns a position or `nil` * Same but in reverse. * If the string can't be parsed to a position, nothing is returned. -* `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions +* `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`: + * returns two positions * Converts a string representing an area box into two positions + * X1, Y1, ... Z2 are coordinates + * `relative_to`: Optional. If set to a position, each coordinate + can use the tilde notation for relative positions + * Tilde notation: "~": Relative coordinate + "~": Relative coordinate plus + * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})` + returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}` * `minetest.formspec_escape(string)`: returns a string * escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs. -- cgit v1.2.3 From fa682270a99383f0f91c37aeed974acc140f34df Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 22 May 2022 19:23:04 +0000 Subject: Add missing comma in example in lua_api.txt (#12339) --- doc/lua_api.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 96b1cc469..f0a8f7c9b 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2012,7 +2012,7 @@ Example definition of the capabilities of an item max_drop_level=1, groupcaps={ crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}} - } + }, damage_groups = {fleshy=2}, } -- cgit v1.2.3 From c660218e43bfbc9740001d6707618d5eba51b664 Mon Sep 17 00:00:00 2001 From: Zughy <63455151+Zughy@users.noreply.github.com> Date: Mon, 23 May 2022 22:49:48 +0200 Subject: Docs: clarify spawn_by for decorations --- doc/lua_api.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index f0a8f7c9b..882c9c54c 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -8560,9 +8560,8 @@ See [Decoration types]. Used by `minetest.register_decoration`. spawn_by = "default:water", -- Node (or list of nodes) that the decoration only spawns next to. - -- Checks two horizontal planes of 8 neighbouring nodes (including - -- diagonal neighbours), one plane level with the 'place_on' node and a - -- plane one node above that. + -- Checks the 8 neighbouring nodes on the same Y, and also the ones + -- at Y+1, excluding both center nodes. num_spawn_by = 1, -- Number of spawn_by nodes that must be surrounding the decoration -- cgit v1.2.3 From f195db2d140a7b4f2f2fbc438680c9d5e23a0d6d Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 25 May 2022 19:29:11 +0200 Subject: Add API function to invoke player respawn closes #12272 --- doc/lua_api.txt | 2 ++ src/script/lua_api/l_object.cpp | 17 +++++++++++++++++ src/script/lua_api/l_object.h | 3 +++ src/server.cpp | 5 +++-- src/server.h | 3 ++- 5 files changed, 27 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 882c9c54c..15a067a5e 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -7099,6 +7099,8 @@ object you are working with still exists. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness) * `get_lighting()`: returns the current state of lighting for the player. * Result is a table with the same fields as `light_definition` in `set_lighting`. +* `respawn()`: Respawns the player using the same mechanism as the death screen, + including calling on_respawnplayer callbacks. `PcgRandom` ----------- diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 39b19364e..37ba1521a 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -2323,6 +2323,21 @@ int ObjectRef::l_get_lighting(lua_State *L) return 1; } +// respawn(self) +int ObjectRef::l_respawn(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + ObjectRef *ref = checkobject(L, 1); + RemotePlayer *player = getplayer(ref); + if (player == nullptr) + return 0; + + getServer(L)->RespawnPlayer(player->getPeerId()); + lua_pushboolean(L, true); + return 1; +} + + ObjectRef::ObjectRef(ServerActiveObject *object): m_object(object) {} @@ -2478,5 +2493,7 @@ luaL_Reg ObjectRef::methods[] = { luamethod(ObjectRef, set_minimap_modes), luamethod(ObjectRef, set_lighting), luamethod(ObjectRef, get_lighting), + luamethod(ObjectRef, respawn), + {0,0} }; diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 3e4e6681a..b36bab492 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -382,4 +382,7 @@ private: // get_lighting(self) static int l_get_lighting(lua_State *L); + + // respawn(self) + static int l_respawn(lua_State *L); }; diff --git a/src/server.cpp b/src/server.cpp index b6330c96a..c775f5d07 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2784,9 +2784,10 @@ void Server::RespawnPlayer(session_t peer_id) << playersao->getPlayer()->getName() << " respawns" << std::endl; - playersao->setHP(playersao->accessObjectProperties()->hp_max, + const auto *prop = playersao->accessObjectProperties(); + playersao->setHP(prop->hp_max, PlayerHPChangeReason(PlayerHPChangeReason::RESPAWN)); - playersao->setBreath(playersao->accessObjectProperties()->breath_max); + playersao->setBreath(prop->breath_max); bool repositioned = m_script->on_respawnplayer(playersao); if (!repositioned) { diff --git a/src/server.h b/src/server.h index 71f692e87..a9c5bcb5f 100644 --- a/src/server.h +++ b/src/server.h @@ -336,6 +336,8 @@ public: void setLighting(RemotePlayer *player, const Lighting &lighting); + void RespawnPlayer(session_t peer_id); + /* con::PeerHandler implementation. */ void peerAdded(con::Peer *peer); void deletingPeer(con::Peer *peer, bool timeout); @@ -529,7 +531,6 @@ private: */ void HandlePlayerDeath(PlayerSAO* sao, const PlayerHPChangeReason &reason); - void RespawnPlayer(session_t peer_id); void DeleteClient(session_t peer_id, ClientDeletionReason reason); void UpdateCrafting(RemotePlayer *player); bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what); -- cgit v1.2.3 From 5cd7b0c6e4551fd53171fba8b30ac9f0a4e13a36 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 26 May 2022 17:41:23 +0200 Subject: Remove remains of video mode querying --- doc/minetest.6 | 2 -- src/client/renderingengine.cpp | 15 --------------- src/client/renderingengine.h | 1 - 3 files changed, 18 deletions(-) (limited to 'doc') diff --git a/doc/minetest.6 b/doc/minetest.6 index 6a3601f80..27a3d0024 100644 --- a/doc/minetest.6 +++ b/doc/minetest.6 @@ -92,8 +92,6 @@ Set password from contents of file .B \-\-random\-input Enable random user input, for testing (client only) .TP -.B \-\-videomodes -List available video modes (client only) .TP .B \-\-speedtests Run speed tests diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 455d5e538..7afca4500 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -638,25 +638,10 @@ float RenderingEngine::getDisplayDensity() #endif -v2u32 RenderingEngine::getDisplaySize() -{ - IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL); - - core::dimension2d deskres = - nulldevice->getVideoModeList()->getDesktopResolution(); - nulldevice->drop(); - - return deskres; -} - #else // __ANDROID__ float RenderingEngine::getDisplayDensity() { return porting::getDisplayDensity(); } -v2u32 RenderingEngine::getDisplaySize() -{ - return porting::getDisplaySize(); -} #endif // __ANDROID__ diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 6f104bba9..38420010f 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -55,7 +55,6 @@ public: static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type); static float getDisplayDensity(); - static v2u32 getDisplaySize(); bool setupTopLevelWindow(const std::string &name); void setupTopLevelXorgWindow(const std::string &name); -- cgit v1.2.3