Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validation(subs,sel)
- if aegisub.frame_from_ms() then
- return true, "True"
- else
- return false, "False"
- end
- end
- function nothing()
- return numeric_table({26, 28, "30-33"}, "37", {_G, {38, "-23--2"}}) -- select a few lines
- --~ return nil
- end
- function numeric_table(...)
- -- Values that are going to be returned
- local values = {}
- -- Table that holds already parsed tables' references for avoiding infinite loops
- local circular = {}
- local function resolve_recursive(t, callback)
- if not type(t) == "table" then return nil; end
- circular[t] = true
- -- Iterate over all values
- for _, v in pairs(t) do
- if type(v) == "table" then
- -- Value is another table, recursive call
- -- But only if it has not already been parsed, since we have those values already
- if not circular[v] then
- resolve_recursive(v, callback)
- end
- else
- callback(v)
- end
- end
- end
- local function parse_value(v)
- -- Check the value for different types and interpret it
- if type(v) == "number" then
- -- Just a number
- table.insert(values, v)
- elseif type(v) == "string" then
- local low, high = v:match("^(-?%d+)-(-?%d+)$")
- -- A range of numbers
- if low and high then
- for low = low, high do
- table.insert(values, low)
- end
- -- The string is convertable
- elseif tonumber(v) then
- table.insert(values, tonumber(v))
- end
- end
- end
- -- Iteterate over all params
- resolve_recursive({...}, parse_value)
- for i, v in ipairs(values) do
- aegisub.log(string.format("values[%d] = %d\n", i, v))
- end
- return values or nil
- end
- aegisub.register_macro("Test","True",nothing,validation)
Advertisement
Add Comment
Please, Sign In to add comment