++, -- Alternative

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)? :open_mouth:
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);

[size=1]This is a joke, but it works ^^[/size]

Wow, what a salesman!

XD

Now allow me to do

X = 1
print(X)
>>1
X =+ 1
print(X)
>>2

:smiley:

Do you even php though

Now allow me to do this

X = 2
X++
print(X) 
>> 3
X--
print(X)
>> 2

[quote] Now allow me to do this

[code]
X = 2
X++
print(X)

3
X–
print(X)

2
[/code] [/quote]

Now we’re getting somewhere.

Now allow me to do this:

[code]“Computer, I want you to define X as two, increment it, print the result, decrement it, and print it again.”

3
2[/code]

[quote] Now allow me to do this:

[code]“Computer, I want you to define X as two, increment it, print the result, decrement it, and print it again.”

3
2[/code] [/quote]

Surely you can just make a computer use keywords in that. IE

define X #
increment it
print
decrement it
print

[quote] Now allow me to do this:

[code]“Computer, I want you to define X as two, increment it, print the result, decrement it, and print it again.”

3
2[/code] [/quote]

Surely you can just make a computer use keywords in that. IE

define X #
increment it
print
decrement it
print[/quote]

Hm, why not ‘print it’ too? That seems like a nice way to refer to last defined variable. Like a dynamic pointer.

[quote] [quote=“um3k” post=46606]Now allow me to do this:

[code]“Computer, I want you to define X as two, increment it, print the result, decrement it, and print it again.”

3
2[/code] [/quote]

Surely you can just make a computer use keywords in that. IE

define X #
increment it
print
decrement it
print[/quote]

Hm, why not ‘print it’ too? That seems like a nice way to refer to last defined variable. Like a dynamic pointer.[/quote]

I think we’ve just invented a new language.

@OriginalPost
wouldn’t it be easier to just define those 2 functions you made instead of creating a new environment
but idk I’m still new to fenvs…