Formatting

This commit is contained in:
AliasAlreadyTaken 2024-04-12 00:01:13 +02:00
parent d0f0a5fb14
commit c66412c415
5 changed files with 16 additions and 25 deletions

15
api.lua
View File

@ -17,19 +17,16 @@ 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
@ -53,9 +50,7 @@ local function set_task(at, func, params, owner, notes)
-- 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)

View File

@ -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

View File

@ -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")

View File

@ -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,7 +325,8 @@ 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" ..
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