diff options
-rw-r--r-- | doc/client_lua_api.txt | 15 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 24 | ||||
-rw-r--r-- | src/script/lua_api/l_clientobject.cpp | 9 | ||||
-rw-r--r-- | src/script/lua_api/l_clientobject.h | 3 |
4 files changed, 32 insertions, 19 deletions
diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt index 20ae5e9d5..83f70bf99 100644 --- a/doc/client_lua_api.txt +++ b/doc/client_lua_api.txt @@ -94,7 +94,7 @@ Mod directory structure The format is documented in `builtin/settingtypes.txt`. It is parsed by the main menu settings dialogue to list mod-specific -settings in the "Clientmods" category. +settings in the "Clientmods" category. ### modname @@ -700,7 +700,7 @@ Call these functions only at load time! * Registers a chatcommand `command` to manage a list that takes the args `del | add | list <param>` * The list is stored comma-seperated in `setting` * `desc` is the description - * `add` adds something to the list + * `add` adds something to the list * `del` del removes something from the list * `list` lists all items on the list * `minetest.register_on_chatcommand(function(command, params))` @@ -1051,7 +1051,7 @@ Passed to `HTTPApiTable.fetch` callback. Returned by * `minetest.register_cheat(name, category, setting | function)` * Register an entry for the cheat menu * If the Category is nonexistant, it will be created - * If the 3rd argument is a string it will be interpreted as a setting and toggled + * If the 3rd argument is a string it will be interpreted as a setting and toggled when the player selects the entry in the cheat menu * If the 3rd argument is a function it will be called when the player selects the entry in the cheat menu @@ -1400,7 +1400,8 @@ This is basically a reference to a C++ `GenericCAO`. * `get_max_hp()`: returns the maximum heath * `punch()`: punches the object * `rightclick()`: rightclicks the object - +* `remove()`: removes the object permanently + ### `Raycast` A raycast on the map. It works with selection boxes. @@ -1792,7 +1793,7 @@ A reference to a C++ InventoryAction. You can move, drop and craft items in all * it specifies how many items to drop / craft / move * `0` means move all items * default count: `0` - + #### example `local move_act = InventoryAction("move") move_act:from("current_player", "main", 1) @@ -1807,7 +1808,7 @@ A reference to a C++ InventoryAction. You can move, drop and craft items in all drop_act:apply() ` * e.g. In first hotbar slot there are tree logs: Move one to craft field, then craft wood out of it and immediately drop it - - + + diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 55f85571d..373d4484a 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -450,10 +450,10 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt) string initialization data } */ - + LocalPlayer *player = m_env.getLocalPlayer(); - bool try_reattach = player && player->isWaitingForReattach(); - + bool try_reattach = player && player->isWaitingForReattach(); + try { u8 type; u16 removed_count, added_count, id; @@ -596,13 +596,13 @@ void Client::handleCommand_Breath(NetworkPacket* pkt) } void Client::handleCommand_MovePlayer(NetworkPacket* pkt) -{ +{ LocalPlayer *player = m_env.getLocalPlayer(); assert(player != NULL); if ((player->getCAO() && player->getCAO()->getParentId()) || player->isWaitingForReattach()) return; - + v3f pos; f32 pitch, yaw; @@ -622,10 +622,10 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt) it would just force the pitch and yaw values to whatever the camera points to. */ - + if (g_settings->getBool("no_force_rotate")) return; - + ClientEvent *event = new ClientEvent(); event->type = CE_PLAYER_FORCE_MOVE; event->player_force_move.pitch = pitch; @@ -833,12 +833,12 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt) *pkt >> pitch; *pkt >> ephemeral; } catch (PacketError &e) {}; - + SimpleSoundSpec sound_spec(name, gain, fade, pitch); - + if (m_mods_loaded && m_script->on_play_sound(sound_spec)) return; - + // Start playing int client_id = -1; switch(type) { @@ -987,10 +987,10 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt) ClientEvent *event = new ClientEvent(); event->type = CE_SPAWN_PARTICLE; event->spawn_particle = new ParticleParameters(p); - + if (m_mods_loaded && m_script->on_spawn_particle(*event->spawn_particle)) return; - + m_client_event_queue.push(event); } diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp index 521aba023..76d0d65ab 100644 --- a/src/script/lua_api/l_clientobject.cpp +++ b/src/script/lua_api/l_clientobject.cpp @@ -173,6 +173,15 @@ int ClientObjectRef::l_rightclick(lua_State *L) return 0; } +int ClientObjectRef::l_remove(lua_State *L) +{ + ClientObjectRef *ref = checkobject(L, 1); + ClientActiveObject *cao = get_cao(ref); + getClient(L)->getEnv().removeActiveObject(cao->getId()); + + return 0; +} + ClientObjectRef::ClientObjectRef(ClientActiveObject *object) : m_object(object) { } diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h index 1ff22407f..ebc0f2a90 100644 --- a/src/script/lua_api/l_clientobject.h +++ b/src/script/lua_api/l_clientobject.h @@ -89,4 +89,7 @@ private: // rightclick(self) static int l_rightclick(lua_State *L); + + // remove(self) + static int l_remove(lua_State *L); }; |