All pastes #136281 Raw Edit

Mine

public text v1 · immutable
#136281 ·published 2006-08-17 16:00 UTC
rendered paste body
--As requested by Spoco here is the LCD Demo for GMod

--Load GMX for our table loading and saving shite
if gmx==nil then _OpenScript("lib/gmx/init.lua") end 

--Declare our table of pixels
Pixel = {}

--Add sizes
WIDTH = 640
HEIGHT = 480

function initPixels()
	for y=1,HEIGHT do
		for x=1,WIDTH do
			Pixel[x] = {}
			Pixel[x][y] = {}
			Pixel[x][y].r = 255
			Pixel[x][y].g = 255
			Pixel[x][y].b = 255
			Pixel[x][y].a = 255 
		end
	end
end

initPixels()

function copyToWorld()
	for y=1,HEIGHT do
		for x=1,WIDTH do
			local colorString=Pixel[x][y].r .. " "..Pixel[x][y].g.." "..Pixel[x][y].b.." " .. Pixel[x][y].a
			local entid = _EntGetByName("pixel"..x"x"..y)
			_EntFire(entid,"color",colorString,0)
		end
	end
end

function savePattern(userid,name)
	gmx.saveTable(Pixel,"lcdpatterns/"..name..".lcd")
end

function loadPattern(userid,name)
	gmx.loadTable("lcdpatterns/"..name..".lcd")
	copyToWorld()
end

CONCOMMAND("savelcd",savePattern)
CONCOMMAND("loadlcd",loadPattern)