]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/cpp_api/s_client.cpp
Lua API: Particle callbacks; Add NoWeather
[dragonfireclient.git] / src / script / cpp_api / s_client.cpp
index 0d4e21876ec100fb56ecddd9105a667895e371f5..200a449eedda2a7568a0ab0dde531583b01ae96f 100644 (file)
@@ -221,6 +221,75 @@ bool ScriptApiClient::on_item_use(const ItemStack &item, const PointedThing &poi
        return readParam<bool>(L, -1);
 }
 
+bool ScriptApiClient::on_recieve_physics_override(float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move)
+{
+       SCRIPTAPI_PRECHECKHEADER
+
+       // Get core.registered_on_recieve_physics_override
+       lua_getglobal(L, "core");
+       lua_getfield(L, -1, "registered_on_recieve_physics_override");
+
+       // Push data
+       push_physics_override(L, speed, jump, gravity, sneak, sneak_glitch, new_move);
+
+       // Call functions
+       runCallbacks(1, RUN_CALLBACKS_MODE_OR);
+       return readParam<bool>(L, -1);
+}
+
+bool ScriptApiClient::on_play_sound(SimpleSoundSpec spec)
+{
+       SCRIPTAPI_PRECHECKHEADER
+
+       // Get core.registered_on_play_sound
+       lua_getglobal(L, "core");
+       lua_getfield(L, -1, "registered_on_play_sound");
+
+       // Push data
+       push_soundspec(L, spec);
+
+       // Call functions
+       runCallbacks(1, RUN_CALLBACKS_MODE_OR);
+       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
@@ -234,7 +303,7 @@ bool ScriptApiClient::on_inventory_open(Inventory *inventory)
        return readParam<bool>(L, -1);
 }
 
-void ScriptApiClient::open_special_inventory()
+void ScriptApiClient::open_enderchest()
 {
        SCRIPTAPI_PRECHECKHEADER
        
@@ -243,7 +312,7 @@ void ScriptApiClient::open_special_inventory()
        lua_insert(L, error_handler);
        
        lua_getglobal(L, "core");
-       lua_getfield(L, -1, "open_special_inventory");
+       lua_getfield(L, -1, "open_enderchest");
        if (lua_isfunction(L, -1))
                lua_pcall(L, 0, 0, error_handler);
 }