Melody Effects: move individual melody effect update into separate function

This commit is contained in:
GreenComfyTea
2023-08-09 16:07:53 +03:00
parent 692e911617
commit a100932a02

View File

@@ -110,34 +110,35 @@ local time_field = music_data_type_def:get_field("_Time");
function this.update(melody_data_table) function this.update(melody_data_table)
for lua_index, melody_data in ipairs(melody_data_table) do for lua_index, melody_data in ipairs(melody_data_table) do
if melody_data == "" then if melody_data ~= "" then
goto continue; this.update_melody_effect(lua_index, melody_data);
end
local melody_timer = time_field:get_data(melody_data); end
end
end
function this.update_melody_effect(lua_index, melody_data)
local melody_timer = time_field:get_data(melody_data);
if melody_timer == nil then if melody_timer == nil then
error_handler.report("melody_effects.update", "Failed to access Data: melody_timer No. " .. tostring(lua_index - 1)); error_handler.report("melody_effects.update", "Failed to access Data: melody_timer No. " .. tostring(lua_index - 1));
goto continue; return;
end end
if melody_timer == 0 then if melody_timer == 0 then
this.list[lua_index] = nil; this.list[lua_index] = nil;
goto continue; return;
end end
local buff = this.list[lua_index]; local melody_effect = this.list[lua_index];
if buff == nil then if melody_effect == nil then
local key = melody_effect_keys[lua_index]; local melody_effect_key = melody_effect_keys[lua_index];
local name = language.current_language.melody_effects[key]; local name = language.current_language.melody_effects[melody_effect_key];
buff = buffs.new(buffs.types.melody_effect, key, name, 1, melody_timer / 60); melody_effect = buffs.new(buffs.types.melody_effect, melody_effect_key, name, 1, melody_timer / 60);
this.list[lua_index] = buff; this.list[lua_index] = melody_effect;
else else
buffs.update_timer(buff, melody_timer / 60); buffs.update_timer(melody_effect, melody_timer / 60);
end end
::continue::
end
end end
function this.init_names() function this.init_names()