User File #64182931488217382

Upload All User Files

#64182931488217382 - Square pixels for 2.4.2

Square pixels.lua
382 downloads
Uploaded 6/21/2020 11:30 AM by dart193 (see all 5)
In 2.4.2, display options seem to be broken, and "1:1 pixel size", also know as square pixels, is not working.
This is the workaround using paddings that will make pixels square again via lua script. It is designed for fullscreen and will apply stretch factor as big as the screen allows.
Screen resolution can be changed in "DesktopResX" and "DesktopResY" variables, default 1920x1080.
The script needs to be launched once and then it automatically readjusts display only if the internal resolution changes. If resolution did not change since the last frame, nothing happens at all, so the performance is not impacted.
--Enter your resolution here
local DesktopResX=1920;
local DesktopResY=1080;
--

local LastResX=0;
local LastResY=0;

while true do
	console.clear();
	NativeResX=client.bufferwidth();
	NativeResY=client.bufferheight();
	if LastResX ~= NativeResX or LastResY ~= NativeResY then
		LastResX=NativeResX;
		LastResY=NativeResY;
		RatioX=NativeResX/DesktopResX;
		RatioY=NativeResY/DesktopResY;
		if RatioX>RatioY then
			Scale=DesktopResX/NativeResX;
		else
			Scale=DesktopResY/NativeResY;
		end;
		Scale=math.floor(Scale);
		ResX=NativeResX*Scale;
		ResY=NativeResY*Scale;
		PadX=(DesktopResX-ResX)/(2*Scale);
		PadY=(DesktopResY-ResY)/(2*Scale);
		client.SetGameExtraPadding(PadX,PadY,PadX,PadY);
	end;
	emu.frameadvance();
end;