aboutsummaryrefslogtreecommitdiffstats
path: root/macros/garret.depctrl_config.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-11-23 20:42:05 +0000
committergarret <garret@airmail.cc>2022-11-23 20:42:05 +0000
commit74feac83bb3a58263eca01823327dce7db347233 (patch)
tree12d2d9c31bc98e3202bec1203d00517585a5517f /macros/garret.depctrl_config.lua
parent9a260cb6d2b34e2e221bd0fb789e74ade3dd467c (diff)
downloadaegisub-scripts-74feac83bb3a58263eca01823327dce7db347233.tar.gz
aegisub-scripts-74feac83bb3a58263eca01823327dce7db347233.tar.bz2
aegisub-scripts-74feac83bb3a58263eca01823327dce7db347233.zip
depctrl global config: don't be stupid
no longer rewrites the entire config below the existing one(!) added forgotten local variables, removed unnecessary ones fixed a typo
Diffstat (limited to 'macros/garret.depctrl_config.lua')
-rw-r--r--macros/garret.depctrl_config.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/macros/garret.depctrl_config.lua b/macros/garret.depctrl_config.lua
index 5e94a76..0a4d4ae 100644
--- a/macros/garret.depctrl_config.lua
+++ b/macros/garret.depctrl_config.lua
@@ -1,7 +1,7 @@
script_name="DepCtrl Global Config"
script_description="the future is now"
script_author = "garret"
-script_version = "1.0.1"
+script_version = "1.1.0"
script_namespace = "garret.depctrl_config"
local DependencyControl = require("l0.DependencyControl")
@@ -35,7 +35,7 @@ local function seconds_to_human(seconds)
local days = math.floor((seconds % 31536000) / 86400)
local hours = math.floor(((seconds % 31536000) % 86400) / 3600)
local minutes = math.floor((((seconds % 31536000) % 86400) % 3600) / 60)
- local seconds = (((seconds % 31536000) % 86400) % 3600) % 60
+ seconds = (((seconds % 31536000) % 86400) % 3600) % 60
--return years, days, hours, minutes, seconds
local timestamp = ""
if years ~= 0 then timestamp = timestamp..years.."y" end
@@ -46,7 +46,7 @@ local function seconds_to_human(seconds)
return timestamp
end
-function human_to_seconds(human)
+local function human_to_seconds(human)
-- im sure this is hideously inefficient
local years = (tonumber(human:match("(%d*)y")) or 0) * 31536000
local days = (tonumber(human:match("(%d*)d")) or 0) * 86400
@@ -159,15 +159,17 @@ local function main()
data_path = data_path:gsub(script_namespace, "l0.DependencyControl")
aegisub.log(4, "config file: "..data_path.."\n")
- data_file = io.open(data_path, "r+")
- data = json.decode(data_file:read())
+ local data_file = io.open(data_path, "r")
+ local data = json.decode(data_file:read())
+ data_file:close()
data.config = get_config(data)
+ local data_str = json.encode(data)
- data_str = json.encode(data)
+ data_file = io.open(data_path, "w")
data_file:write(data_str)
data_file:close()
aegisub.log(3, "Done. You'll need to rescan your automation directory, or restart aegisub, for the changes to take effect.")
end
-depctrl:registerMacro("DependencyControl/Global Configuration", "Lets you change DepedencyControl settings.", main)
+depctrl:registerMacro("DependencyControl/Global Configuration", "Lets you change DependencyControl settings.", main)