Script: Luar

-- Check if a value exists in a table (linear search) function table_utils.contains(tbl, value) for _, v in pairs(tbl) do if v == value then return true end end return false end

-- Check if value is a number within range function validate.is_in_range(val, min, max) return type(val) == "number" and val >= min and val <= max end script luar

-- Check if string matches a pattern (regex-lite) function validate.matches_pattern(str, pattern) return string.match(str, pattern) ~= nil end -- Check if a value exists in a

-- Write string to file (overwrites) function file_utils.write_file(filename, content) local f, err = io.open(filename, "w") if not f then return false, err end f:write(content) f:close() return true end value) for _

-- -------------------------------------------- -- 3. FILE I/O (safe read/write) -- -------------------------------------------- local file_utils = {}

-- ============================================ -- UTILITY SCRIPT FOR LUA (5.1+ compatible) -- Author: Generated Assistant -- Description: Reusable functions for string, table, file, and debug tasks -- ============================================

-- Merge table t2 into t1 (overwrites t1 keys) function table_utils.merge(t1, t2) for k, v in pairs(t2) do t1[k] = v end return t1 end