From a3fd1a5462fe1c56b654d91bad8afac81f9d1f4e Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Wed, 24 Dec 2025 23:16:10 +0100 Subject: [PATCH] on_state --- plugin.lua | 4 ++++ src/lua_rds.c | 2 ++ src/rds.c | 1 + 3 files changed, 7 insertions(+) diff --git a/plugin.lua b/plugin.lua index 770c521..ea93638 100644 --- a/plugin.lua +++ b/plugin.lua @@ -24,6 +24,10 @@ function on_init() end ---It should be defined by the user in the script. ---@return nil function on_start() end +---This function is called every time when the state resets, register your odas here +---It should be defined by the user in the script. +---@return nil +function on_state() end ---This function is called every second ---It should be defined by the user in the script. ---@return nil diff --git a/src/lua_rds.c b/src/lua_rds.c index 1643023..9d77b3b 100644 --- a/src/lua_rds.c +++ b/src/lua_rds.c @@ -12,6 +12,7 @@ int lua_set_rds_program_defaults(lua_State *localL) { unload_refs[0] = 0; set_rds_defaults(mod->enc, mod->enc->program); lua_call_function("on_init"); + lua_call_function("on_state"); return 0; } @@ -25,6 +26,7 @@ int lua_reset_rds(lua_State *localL) { encoder_loadFromFile(mod->enc); for(int i = 0; i < PROGRAMS; i++) reset_rds_state(mod->enc, i); Modulator_loadFromFile(&mod->params); + lua_call_function("on_state"); return 0; } diff --git a/src/rds.c b/src/rds.c index 63f23d3..39efc0a 100644 --- a/src/rds.c +++ b/src/rds.c @@ -414,5 +414,6 @@ void init_rds_encoder(RDSEncoder* enc) { } for(int i = 0; i < PROGRAMS; i++) reset_rds_state(enc, i); lua_call_function("on_start"); + lua_call_function("on_state"); encoder_saveToFile(enc); } \ No newline at end of file