我如何在Lua中的特定日期特定时间执行全局函数?

我正在使用Lua编写一个脚本,其中包括许多其他功能,还将在特定时间的特定日期执行单个循环。当按下按钮时启动循环,我已经思考了一段时间,发现我必须使用os.time检查毫秒级系统时间,它可以以表格形式返回日期,这非常有帮助。我卡在的唯一问题是如何表达它,以及是否可能包括多个os.time的定义;因此,在x天上运行loop1,y天上发生loop2等。我可能过于复杂化了...

到目前为止,这是我的代码:(当按下按钮调用时会崩溃和失败)

function runiftime()

day1 = a;
day2 = b;
day3 = c;
day4 = d;
status = 0; -- 默认状态 == 0
target = day4;

-- 在上面所示的a,b,c和d中,我希望不同的os.time输出与将来的某一天相关,os.time的示例输出为 = os.time()输出'1384988715'。

    repeat

 if os.time() == "day1" then

    os.execute("Some command");
    result = Shell.Execute("Some program", "open", "", "",     SW_SHOWNORMAL, false);
    status = 1;
end

 if os.time() == "day2" then

    os.execute("Some command");
    result = Shell.Execute("Some program", "open", "", "", SW_SHOWNORMAL, false);
    status = 1;
end

 if os.time == "day3" then

    os.execute("Some command");
    result = Shell.Execute("Some program", "open", "", "",     SW_SHOWNORMAL, false);
    status = 1;
end

 if os.time == "day4" then

    os.execute("Some command");
    result = Shell.Execute("Some program", "open", "", "",     SW_SHOWNORMAL, false);
    status = 1;
end

    if status == 1 then
        Input.SetText("feed", "Routine Successful!                                  Waiting for Command...");
    else
        Input.SetText("feed", "Automated Routine Started!           Waiting for OS Clock...");
    end

until (os.time == target);
end
点赞