args = {...} local h = fs.open(args[1], 'r') data = h.readAll() h.close() local old_mt = debug.getmetatable("") local mt = {} local error_msg = "attempt to perform arithmetic on %s and %s" debug.setmetatable("",mt) mt.__add = function (op1, op2) op1 = op1 or 'nil' op2 = op2 or 'nil' if ((type(op1) == 'table' or type(op1) == 'function') or (type(op2) == 'table' or type(op2) == 'function')) then error(string.format(error_msg, type(op1), type(op2)), 2) end return (type(op1) == 'boolean' and (op1 and 'true' or 'false') or op1) .. (type(op2) == 'boolean' and (op2 and 'true' or 'false') or op2) end mt.__sub = function (op1, op2) if(type(op1) == 'number') then return string.sub(op2, 1+op1, #op2) elseif(type(op2) == 'number') then return string.sub(op1, 1, #op1-op2) end return error(string.format(error_msg, type(op1), type(op2)), 2) end mt.__mul = function (op1, op2) if(type(op1) == 'number') then local tmp = '' for i=1, op1 do tmp = tmp .. op2 end return tmp elseif(type(op2) == 'number') then local tmp = '' for i=1, op2 do tmp = tmp .. op1 end return tmp end return error(string.format(error_msg, type(op1), type(op2)), 2) end mt.__div = function (op1, op2) if not type(op1) == 'string' then return error(string.format(error_msg, type(op1), type(op2)), 2) end if(type(op2) == 'number') then return {string.match(op1, string.rep(('('..string.rep(('.?'), op2)..')'), math.floor(#op1/(op2))))} elseif(type(op2) == 'string') then local match = "([^"..op2.."]+)" if op2 == '' then match = "(.*)" end local t={} for str in string.gmatch(op1, match) do table.insert(t, str) end return t end return error(string.format(error_msg, type(op1), type(op2)), 2) end mt.__mod = function (op1, op2) if not type(op1) == 'string' then return error(string.format(error_msg, type(op1), type(op2)), 2) end if(type(op2) == 'number') then return string.sub(op1, -(#op1%op2), -(#op1%op2)) end return error(string.format(error_msg, type(op1), type(op2)), 2) end mt.__unm = function(op1) return string.reverse(op1) end loadstring(data)() debug.setmetatable("", old_mt)