What exactly is the purpose of this script? What could it be for?

I came across something, it was on my computer, I don’t know if I wrote it or if someone else wrote it, I have no idea. What could this be used for, what do you think it’s for? It has no comments and no name i’m really curious as to what this is…



server = {};
server.bootvars = { "SERVER_MAX_SLOTS" };
server.config = {};
server.memory = {};
server.ports = {};
server.online = false;

function server:boot()
	for k,v in pairs( self.bootvars ) do
		if ( self.config[v] == nil ) then
			print("SERVER INSTANCE COULD NOT BE STARTED DUE TO MISSING PARAMETERS ON BOOT.( " .. v .. ").");
			return;
		end
	end
	
	for i=1, self.config["SERVER_MAX_SLOTS"] do
		self.ports* = {};
		self.ports*.connected = false;
		self.ports*.portnumber = i;
		self.ports*.user = nil;
	end
	
	self.online = true;
end

function server:setParameter( parameter, value )
	self.config[parameter] = value;
end

function server:getParameter( parameter )
	return self.config[parameter] or nil;
end

function server:onUserConnect(player,port)
	print( player:SteamID() .. " connected on port " .. port .. " !");
end

function server:openInstance( tbl )
	tbl = tbl or { };
	
	setmetatable( tbl, self );
	self.__index = self;
	return tbl;
end

function server:connectUser(player)
	if ( self.online == false ) then return end;
	
	-- find a open port
	for port,data in pairs( self.ports ) do
		if ( data.connected == false ) then
			self.ports[port].connected = true;
			self.ports[port].user = player;
			self:onUserConnect(player,port);
			return;
		end
	end
end

function server:disconnectUser(player)
	if ( self.online == false ) then return end;
	
	for port,data in pairs( self.ports ) do
		if ( data.user != nil ) then
			if ( data.user == player ) then
				self.ports[port].connected = false;
				self.ports[port].user = nil;
			end
		end
	end
end

function server:setMemoryCellVar(cell,var,value)
	if ( self.memory[cell] == nil ) then
		self.memory[cell] = {};
	end
	
	self.memory[cell][var] = value;
end

function server:getMemoryCellVar(cell,var)
	if ( self.memory[cell] == nil ) then return nil; end;
	if ( self.memory[cell][var] == nil ) then return nil; end;
	return self.memory[cell][var];
end

// not done
function server:networkVarToPorts(var)
	for port,data in pairs( self.ports ) do
		if ( data.connected == true ) then
			local user = data.user;
			umsg.Start("instanceNetworkVar", user );
				if ( type(var) == "string" ) then
					umsg.String("string");
					umsg.String(var);
				elseif( type(var) == "number" ) then
					umsg.String("number");
					umsg.Short( var );
				end
			umsg.End();
		end
	end
end

include( "world.lua" );

----
-- test
----
INSTANCE_ONE = server:openInstance();

local instance = INSTANCE_ONE;
instance:setParameter( "SERVER_MAX_SLOTS", 5 );
instance:boot();


could it be for having multiple instances of a server running on one server? ( didnt say that properly , i hope you got the idea though )

It’s an interesting script though

i looked in the world.lua that is included in there, it renders a grid, i think this was meant to be a 2d game i was making sometime a long time ago.

http://filesmelt.com/dl/grid1.png



-----
-- ALPHA!
-----

world = {};
world.grid = {};
function world:generateRandomSize()
	return math.random( 100, 500 );
end

function world:generate(numRooms)
	if ( numRooms == nil ) then
		numRooms = self:generateRandomSize();
	end
	
	for tile=1,numRooms do
		self.grid[tile] = {};
		self.grid[tile].tilenumber = tile;
		self.grid[tile].texture = "";
	end
end

function world:getTile(tile)
	return self.grid[tile] or nil;
end

function world:rendergrid(rowsize)
	self.renderGrid = {};
	
	-- The number of how many rows.
	local NumRows = #self.grid / rowsize;
	
	local startRow = 1;
	local endRow = 1*rowsize;
	
	for row=1, NumRows do
	
		self.renderGrid[row] = {};
		
		for tile=startRow, endRow do
		
			self.renderGrid[row][tile] = self.grid[tile];
			
			if ( tile == endRow ) then
				-- do the math the loop is gonna end.
				startRow = endRow;
				endRow = endRow + rowsize;
			end
		end
	end
end

function world:getRenderGrid()
	return self.renderGrid;
end


world:generate(100);
world:rendergrid(10);


That is probably the reason I put everything into my TEMP folder and then delete everything in there.

That way I don’t find files and ask myself a question “Wtf is this?”

just for the hell of it, look what i done did:

http://filesmelt.com/dl/grid2.png



function GM:HUDPaint()
	local GRID_ORIGIN_X = 5;
	local GRID_ORIGIN_Y = 5;
	local RENDER_GRID = world:getRenderGrid();
	
	local TILE_POSITION_X = GRID_ORIGIN_X;
	local TILE_POSITION_Y = GRID_ORIGIN_Y;
	
	for _,row in pairs( RENDER_GRID ) do
		
		for k,v in pairs( row ) do
			draw.TexturedQuad({
				texture = surface.GetTextureID(v.texture),
				color = Color(255, 255, 255, 150),
				x = TILE_POSITION_X,
				y = TILE_POSITION_Y,
				w = 20,
				h = 20
			});
			TILE_POSITION_X = TILE_POSITION_X + 20;
		end
		
		TILE_POSITION_Y = TILE_POSITION_Y + 20;
		TILE_POSITION_X = GRID_ORIGIN_X;
	end
end


okay now let this thread die because i feel stupid for forgetting my own work.