diff --git a/api.lua b/api.lua index 1be1ff0..c218c1e 100644 --- a/api.lua +++ b/api.lua @@ -17,25 +17,22 @@ local function set_task(at, func, params, owner, notes) -- Defense -- Those values come from files and chatcommands - local validate_success, validate_message = yl_scheduler.validate(at, func, params, owner, notes) - if (validate_success == false) then - return false, validate_message - end + local validate_success, validate_message = + yl_scheduler.validate(at, func, params, owner, notes) + if (validate_success == false) then return false, validate_message end local task = {} -- UUID local get_uuid_success, UUID = yl_scheduler.create_uuid() - if get_uuid_success == false then - return false, UUID - end + if get_uuid_success == false then return false, UUID end task.id = UUID -- at - -- Try to find what timeformat we are - -- Caclulate utc time from this given time format + -- Try to find what timeformat we are + -- Caclulate utc time from this given time format task.at = at -- func @@ -48,14 +45,12 @@ local function set_task(at, func, params, owner, notes) task.owner = owner -- notes, optional - task.notes= notes or "" + task.notes = notes or "" -- save to file local write_file_success = yl_scheduler.save_json(UUID, task) - if write_file_success == false then - return false, "Cannot write file" - end + if write_file_success == false then return false, "Cannot write file" end -- store in table table.insert(yl_scheduler.tasks, task) diff --git a/chatcommands.lua b/chatcommands.lua index 47c048d..8644008 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -1,4 +1,4 @@ dofile(yl_scheduler.modpath .. "chatcommand_scheduler_add.lua") dofile(yl_scheduler.modpath .. "chatcommand_scheduler_remove.lua") dofile(yl_scheduler.modpath .. "chatcommand_scheduler_list.lua") -dofile(yl_scheduler.modpath .. "chatcommand_scheduler_clean.lua") \ No newline at end of file +dofile(yl_scheduler.modpath .. "chatcommand_scheduler_clean.lua") diff --git a/globalsteps.lua b/globalsteps.lua index f4dc1ba..894adc7 100644 --- a/globalsteps.lua +++ b/globalsteps.lua @@ -2,9 +2,7 @@ local timer = 0 local gs = function(dtime) timer = timer + dtime - if timer <= yl_scheduler.config.interval then - return - end + if timer <= yl_scheduler.config.interval then return end timer = 0 -- do stuff diff --git a/init.lua b/init.lua index cc90f65..d8c74ae 100644 --- a/init.lua +++ b/init.lua @@ -1,9 +1,7 @@ -- Version 0.0.1 -- Author AliasAlreadyTaken -- License MIT - -- Changelog - local mod_start_time = minetest.get_us_time() minetest.log("action", "[MOD] yl_scheduler loading") @@ -26,7 +24,7 @@ dofile(yl_scheduler.modpath .. "setup.lua") dofile(yl_scheduler.modpath .. "internal.lua") dofile(yl_scheduler.modpath .. "api.lua") dofile(yl_scheduler.modpath .. "initialize.lua") ---dofile(yl_scheduler.modpath .. "globalsteps.lua") +-- dofile(yl_scheduler.modpath .. "globalsteps.lua") dofile(yl_scheduler.modpath .. "chatcommands.lua") local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000 diff --git a/internal.lua b/internal.lua index 3302ac9..23b8193 100644 --- a/internal.lua +++ b/internal.lua @@ -226,7 +226,6 @@ local function load_all_tasks() end -- Sort table for "at" - -- TODO: What's more efficient? Sort by at? use index with UUID? yl_scheduler.tasks = sort_by_timestamp(tasks) if bad == 0 then @@ -326,16 +325,17 @@ local function cmd_scheduler_add(name, c_params) "Separate time, function, parameters, mask and notes with $\n" .. "Example: /scheduler_add 1712679465$minetest.log$action,mytext$string,string$mynotes\n" elseif c_params == "helpmask" then - return true, "Provide a parameter mask to convert the parameters to number or table" .. - "Allowed values are \"string\",\"number\",\"table\"" .. - "If your use case requires other types, please create a wrapper function." + return true, + "Provide a parameter mask to convert the parameters to number or table" .. + "Allowed values are \"string\",\"number\",\"table\"" .. + "If your use case requires other types, please create a wrapper function." end local t_parameters = string.split(c_params, "$", true) local at = tonumber(t_parameters[1]) local func = t_parameters[2] - --local string_params = string.split(t_parameters[3], ",") -- optional + -- local string_params = string.split(t_parameters[3], ",") -- optional local params = string.split(t_parameters[3], ",") -- optional local mask = string.split(t_parameters[4], ",") or {} -- optional local owner = name or "N/A"