aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/network/clientpackethandler.cpp5
-rw-r--r--src/script/common/c_content.cpp51
-rw-r--r--src/script/common/c_content.h1
-rw-r--r--src/script/cpp_api/s_client.cpp37
-rw-r--r--src/script/cpp_api/s_client.h2
6 files changed, 80 insertions, 17 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 141070003..bcf5012a9 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -146,6 +146,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_node_tracers", "false");
settings->setDefault("entity_esp_color", "(255, 255, 255)");
settings->setDefault("player_esp_color", "(0, 255, 0)");
+ settings->setDefault("noweather", "false");
// Keymap
settings->setDefault("remote_port", "30000");
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index c39586f2c..55f85571d 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -988,9 +988,8 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt)
event->type = CE_SPAWN_PARTICLE;
event->spawn_particle = new ParticleParameters(p);
- if (g_settings->getBool("log_particles")) {
- std::cout << p.pos.X << " " << p.pos.Y << " " << p.pos.Z << std::endl;
- }
+ if (m_mods_loaded && m_script->on_spawn_particle(*event->spawn_particle))
+ return;
m_client_event_queue.push(event);
}
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 04f4c335c..72361bdb5 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -1325,20 +1325,6 @@ void push_inventory(lua_State *L, Inventory *inventory)
}
/******************************************************************************/
-void push_inventory_list(lua_State *L, Inventory *inv, const char *name)
-{
- InventoryList *invlist = inv->getList(name);
- if(invlist == NULL){
- lua_pushnil(L);
- return;
- }
- std::vector<ItemStack> items;
- for(u32 i=0; i<invlist->getSize(); i++)
- items.push_back(invlist->getItem(i));
- push_items(L, items);
-}
-
-/******************************************************************************/
void read_inventory_list(lua_State *L, int tableindex,
Inventory *inv, const char *name, Server* srv, int forcesize)
{
@@ -1367,6 +1353,19 @@ void read_inventory_list(lua_State *L, int tableindex,
}
}
+void push_inventory_list(lua_State *L, Inventory *inv, const char *name)
+{
+ InventoryList *invlist = inv->getList(name);
+ if(invlist == NULL){
+ lua_pushnil(L);
+ return;
+ }
+ std::vector<ItemStack> items;
+ for(u32 i=0; i<invlist->getSize(); i++)
+ items.push_back(invlist->getItem(i));
+ push_items(L, items);
+}
+
/******************************************************************************/
struct TileAnimationParams read_animation_definition(lua_State *L, int index)
{
@@ -1402,6 +1401,29 @@ struct TileAnimationParams read_animation_definition(lua_State *L, int index)
return anim;
}
+void push_animation_definition(lua_State *L, struct TileAnimationParams anim)
+{
+ switch (anim.type) {
+ case TAT_NONE:
+ lua_pushnil(L);
+ break;
+ case TAT_VERTICAL_FRAMES:
+ lua_newtable(L);
+ setstringfield(L, -1, "type", "vertical_frames");
+ setfloatfield(L, -1, "aspect_w", anim.vertical_frames.aspect_w);
+ setfloatfield(L, -1, "aspect_h", anim.vertical_frames.aspect_h);
+ setfloatfield(L, -1, "length", anim.vertical_frames.length);
+ break;
+ case TAT_SHEET_2D:
+ lua_newtable(L);
+ setstringfield(L, -1, "type", "sheet_2d");
+ setintfield(L, -1, "frames_w", anim.sheet_2d.frames_w);
+ setintfield(L, -1, "frames_h", anim.sheet_2d.frames_h);
+ setintfield(L, -1, "frame_length", anim.sheet_2d.frame_length);
+ break;
+ }
+}
+
/******************************************************************************/
ToolCapabilities read_tool_capabilities(
lua_State *L, int table)
@@ -2103,6 +2125,7 @@ void push_collision_move_result(lua_State *L, const collisionMoveResult &res)
/**/
}
+/******************************************************************************/
void push_physics_override(lua_State *L, float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move)
{
lua_createtable(L, 0, 6);
diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h
index 08c74c292..10b77a116 100644
--- a/src/script/common/c_content.h
+++ b/src/script/common/c_content.h
@@ -98,6 +98,7 @@ void push_hit_params (lua_State *L,
ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
struct TileAnimationParams read_animation_definition(lua_State *L, int index);
+void push_animation_definition(lua_State *L, struct TileAnimationParams anim);
ToolCapabilities read_tool_capabilities (lua_State *L, int table);
void push_tool_capabilities (lua_State *L,
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index cf7df5b5d..200a449ee 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -253,6 +253,43 @@ bool ScriptApiClient::on_play_sound(SimpleSoundSpec spec)
return readParam<bool>(L, -1);
}
+bool ScriptApiClient::on_spawn_particle(struct ParticleParameters param)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_play_sound
+
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_spawn_particle");
+
+ // Push data
+ lua_newtable(L);
+ push_v3f(L, param.pos);
+ lua_setfield(L, -2, "pos");
+ push_v3f(L, param.vel);
+ lua_setfield(L, -2, "velocity");
+ push_v3f(L, param.acc);
+ lua_setfield(L, -2, "acceleration");
+ setfloatfield(L, -1, "expirationtime", param.expirationtime);
+ setboolfield(L, -1, "collisiondetection", param.collisiondetection);
+ setboolfield(L, -1, "collision_removal", param.collision_removal);
+ setboolfield(L, -1, "object_collision", param.object_collision);
+ setboolfield(L, -1, "vertical", param.vertical);
+ push_animation_definition(L, param.animation);
+ lua_setfield(L, -2, "animation");
+ setstringfield(L, -1, "texture", param.texture);
+ setintfield(L, -1, "glow", param.glow);
+ if (param.node.getContent() != CONTENT_IGNORE) {
+ pushnode(L, param.node, getGameDef()->ndef());
+ lua_setfield(L, -2, "node");
+ }
+ setintfield(L, -1, "node_tile", param.node_tile);
+
+ // Call functions
+ runCallbacks(1, RUN_CALLBACKS_MODE_OR);
+ return readParam<bool>(L, -1);
+}
+
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
{
SCRIPTAPI_PRECHECKHEADER
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index 8db253d56..ff1c473ae 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "util/pointedthing.h"
#include "lua_api/l_item.h"
+#include "particles.h"
#ifdef _CRT_MSVCP_CURRENT
#include <cstdint>
@@ -59,6 +60,7 @@ public:
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
bool on_recieve_physics_override(float override_speed, float override_jump, float override_gravity, bool sneak, bool sneak_glitch, bool new_move);
bool on_play_sound(SimpleSoundSpec spec);
+ bool on_spawn_particle(struct ParticleParameters param);
bool on_inventory_open(Inventory *inventory);
void open_enderchest();