Lua API: Particle callbacks; Add NoWeather
This commit is contained in:
parent
0a285dd338
commit
8b3eaf5b05
@ -39,6 +39,7 @@ core.cheats = {
|
|||||||
["PlayerTracers"] = "enable_player_tracers",
|
["PlayerTracers"] = "enable_player_tracers",
|
||||||
["NodeESP"] = "enable_node_esp",
|
["NodeESP"] = "enable_node_esp",
|
||||||
["NodeTracers"] = "enable_node_tracers",
|
["NodeTracers"] = "enable_node_tracers",
|
||||||
|
["NoWeather"] = "noweather",
|
||||||
},
|
},
|
||||||
["World"] = {
|
["World"] = {
|
||||||
["FastDig"] = "fastdig",
|
["FastDig"] = "fastdig",
|
||||||
|
@ -1,2 +1,14 @@
|
|||||||
core.register_list_command("xray", "Configure X-Ray", "xray_nodes")
|
core.register_list_command("xray", "Configure X-Ray", "xray_nodes")
|
||||||
core.register_list_command("search", "Configure NodeESP", "node_esp_nodes")
|
core.register_list_command("search", "Configure NodeESP", "node_esp_nodes")
|
||||||
|
|
||||||
|
core.register_on_spawn_particle(function(particle)
|
||||||
|
if core.settings:get_bool("noweather") and particle.texture:sub(1, 12) == "weather_pack" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_play_sound(function(sound)
|
||||||
|
if core.settings:get_bool("noweather") and sound.name == "weather_rain" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
@ -104,3 +104,4 @@ core.registered_on_modchannel_signal, core.register_on_modchannel_signal = make_
|
|||||||
core.registered_on_inventory_open, core.register_on_inventory_open = make_registration()
|
core.registered_on_inventory_open, core.register_on_inventory_open = make_registration()
|
||||||
core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration()
|
core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration()
|
||||||
core.registered_on_play_sound, core.register_on_play_sound = make_registration()
|
core.registered_on_play_sound, core.register_on_play_sound = make_registration()
|
||||||
|
core.registered_on_spawn_particle, core.register_on_spawn_particle = make_registration()
|
||||||
|
@ -2366,3 +2366,5 @@ enable_node_tracers (NodeTracers) bool false
|
|||||||
entity_esp_color (EntityESP Color) v3f 255, 255, 255
|
entity_esp_color (EntityESP Color) v3f 255, 255, 255
|
||||||
|
|
||||||
player_esp_color (PlayerESP Color) v3f 0, 255, 0
|
player_esp_color (PlayerESP Color) v3f 0, 255, 0
|
||||||
|
|
||||||
|
noweather (NoWeather) bool false
|
||||||
|
@ -755,10 +755,14 @@ Call these functions only at load time!
|
|||||||
* Called when recieving physics_override from server
|
* Called when recieving physics_override from server
|
||||||
* Newest functions are called first
|
* Newest functions are called first
|
||||||
* If any function returns true, the physics override does not change
|
* If any function returns true, the physics override does not change
|
||||||
* `minetest.register_on_sound_play(function(SimpleSoundSpec))`
|
* `minetest.register_on_play_sound(function(SimpleSoundSpec))`
|
||||||
* Called when recieving a play sound command from server
|
* Called when recieving a play sound command from server
|
||||||
* Newest functions are called first
|
* Newest functions are called first
|
||||||
* If any function returns true, the sound does not play
|
* If any function returns true, the sound does not play
|
||||||
|
* `minetest.register_on_spawn_partice(function(particle definition))`
|
||||||
|
* Called when recieving a spawn particle command from server
|
||||||
|
* Newest functions are called first
|
||||||
|
* If any function returns true, the particel does not spawn
|
||||||
|
|
||||||
### Setting-related
|
### Setting-related
|
||||||
* `minetest.settings`: Settings object containing all of the settings from the
|
* `minetest.settings`: Settings object containing all of the settings from the
|
||||||
|
@ -146,6 +146,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("enable_node_tracers", "false");
|
settings->setDefault("enable_node_tracers", "false");
|
||||||
settings->setDefault("entity_esp_color", "(255, 255, 255)");
|
settings->setDefault("entity_esp_color", "(255, 255, 255)");
|
||||||
settings->setDefault("player_esp_color", "(0, 255, 0)");
|
settings->setDefault("player_esp_color", "(0, 255, 0)");
|
||||||
|
settings->setDefault("noweather", "false");
|
||||||
|
|
||||||
// Keymap
|
// Keymap
|
||||||
settings->setDefault("remote_port", "30000");
|
settings->setDefault("remote_port", "30000");
|
||||||
|
@ -988,9 +988,8 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt)
|
|||||||
event->type = CE_SPAWN_PARTICLE;
|
event->type = CE_SPAWN_PARTICLE;
|
||||||
event->spawn_particle = new ParticleParameters(p);
|
event->spawn_particle = new ParticleParameters(p);
|
||||||
|
|
||||||
if (g_settings->getBool("log_particles")) {
|
if (m_mods_loaded && m_script->on_spawn_particle(*event->spawn_particle))
|
||||||
std::cout << p.pos.X << " " << p.pos.Y << " " << p.pos.Z << std::endl;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_client_event_queue.push(event);
|
m_client_event_queue.push(event);
|
||||||
}
|
}
|
||||||
|
@ -1324,20 +1324,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,
|
void read_inventory_list(lua_State *L, int tableindex,
|
||||||
Inventory *inv, const char *name, Server* srv, int forcesize)
|
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)
|
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;
|
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(
|
ToolCapabilities read_tool_capabilities(
|
||||||
lua_State *L, int table)
|
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)
|
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);
|
lua_createtable(L, 0, 6);
|
||||||
|
@ -98,6 +98,7 @@ void push_hit_params (lua_State *L,
|
|||||||
ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
|
ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
|
||||||
|
|
||||||
struct TileAnimationParams read_animation_definition(lua_State *L, int index);
|
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);
|
ToolCapabilities read_tool_capabilities (lua_State *L, int table);
|
||||||
void push_tool_capabilities (lua_State *L,
|
void push_tool_capabilities (lua_State *L,
|
||||||
|
@ -253,6 +253,43 @@ bool ScriptApiClient::on_play_sound(SimpleSoundSpec spec)
|
|||||||
return readParam<bool>(L, -1);
|
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)
|
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "util/pointedthing.h"
|
#include "util/pointedthing.h"
|
||||||
#include "lua_api/l_item.h"
|
#include "lua_api/l_item.h"
|
||||||
|
#include "particles.h"
|
||||||
|
|
||||||
#ifdef _CRT_MSVCP_CURRENT
|
#ifdef _CRT_MSVCP_CURRENT
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -59,6 +60,7 @@ public:
|
|||||||
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
|
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_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_play_sound(SimpleSoundSpec spec);
|
||||||
|
bool on_spawn_particle(struct ParticleParameters param);
|
||||||
|
|
||||||
bool on_inventory_open(Inventory *inventory);
|
bool on_inventory_open(Inventory *inventory);
|
||||||
void open_enderchest();
|
void open_enderchest();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user