Script - Luar

-- Simple execution timer (prints elapsed time) function debug_utils.time_function(func, ...) local start = os.clock() local results = {func(...)} local elapsed = os.clock() - start print(string.format("Execution time: %.4f seconds", elapsed)) return table.unpack(results) end

-- -------------------------------------------- -- 2. TABLE UTILITIES -- -------------------------------------------- local table_utils = {} script luar

-- ============================================ -- UTILITY SCRIPT FOR LUA (5.1+ compatible) -- Author: Generated Assistant -- Description: Reusable functions for string, table, file, and debug tasks -- ============================================ -- Simple execution timer (prints elapsed time) function

file_utils.write_file("test.txt", "Lua rocks!") print(file_utils.read_file("test.txt")) t2) for k

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

-- -------------------------------------------- -- 6. EXAMPLE USAGE (commented out) -- -------------------------------------------- --[[ local my_string = " hello world " print(string_utils.trim(my_string)) --> "hello world" local parts = string_utils.split("a,b,c", ",") --> {"a","b","c"}

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