Are you lazy?
Do you not like writing “x = x + 1” JUST TO INCREASE A VARIABLE?
Of course you are! … admit it…
Do you want a way to rid of the exhausting energy it takes to type ALL THAT?
Would you like a pointless script that allows you to write up(x) and EVEN down(x)?
OF COURSE YOU WOULD!
May all your wishes come true, fellow lazy ones
local old = getfenv();
local oldprint = print;
local olderror = error;
local env = {
['up'] = function(x)
local type = type(x);
if type ~= 'table' then
error("HAH U TRY TO BREAK ME",0);
elseif type == 'table' then
x[2] = x[2] + 1;
end
end,
['down'] = function(x)
local type = type(x);
if type ~= 'table' then
error("HAH U TRY TO BREAK ME",0);
elseif type == 'table' then
x[2] = x[2] - 1;
end
end,
['print'] = function(...)
local args = {...};
for _,v in pairs(args) do
if type(v) == 'table' and v[1]:find('!') then
oldprint(v[2]);
else
oldprint(v);
end
end
end
};
local metamethods = {
__index = function(s,i)
if old[i] then
return old[i];
elseif s[i] then
return s[i];
end
end,
__newindex = function(s,i,v)
if type(v) == 'number' then
rawset(s,i,{'!'..i,v});
end
end
}
setfenv(1,setmetatable(env,metamethods));
print('\n');
x = 3;
up(x);
print(x);
down(x);
print(x);