Does anyone know whether you can use overloads in CS2D functions, and of course if you do, how so.
Its not vitally important that I use overloads, as all it is doing is removeing unused variables, but it would be nice.
function spawnPlayer(...) 	funcs={ 		function(id) 			parse("spawnplayer "..id.." 32 32") 		end, 		function(id,x) 			parse("spawnplayer "..id.." "..x.." "..math.ceil(math.random())) 		end, 		function(id,x,y) 			parse("spawnplayer "..id.." "..x.." "..y) 		end 	} 	funcs[#arg](unpack(arg)) end spawnPlayer(1) --> Spawn player 1 @ x:32|y:32 spawnPlayer(1,64) --> Spawn player 1 @ x:64|y:random spawnPlayer(1,64,128) --> Spawn player 1 @ x:64|y:128
function a() 	print(1) end
a=function() 	print(1) end
function f(x, y) 	return math.sqrt(x^2 + y^2) end function f(x, y, z) 	return math.sqrt(x^2 + y^2 + z^2) end
function a() 	local b=function(a) 			print("1 "..a) 		end 	b=function(a,b) 		print("2 "..a.." "..b) 	end 	return a(1),a(1,2) end a()
do 	local f = function() end 	do 		local f = function(x) end 		do 			... 		end 	end end
function test() 	local f = function(a) 		print("1", a) 	end 	f = function(a, b) 		print("2", b) 	end end
function <test.lua:1,9> (3 instructions, 12 bytes at 00258E30) 0 params, 2 slots, 0 upvalues, 1 local, 0 constants, 2 functions 1 [4] CLOSURE 0 0 ; 00258F90 2 [8] CLOSURE 0 1 ; 00597E90
function <test.lua:2,4> (5 instructions, 20 bytes at 00258F90) 1 param, 4 slots, 0 upvalues, 1 local, 2 constants, 0 functions 1 [3] GETGLOBAL 1 -1 ; print 2 [3] LOADK 2 -2 ; "1" 3 [3] MOVE 3 0 4 [3] CALL 1 3 1 5 [4] RETURN 0 1
function <test.lua:2,4> (5 instructions, 20 bytes at 00258F90) 1 param, 4 slots, 0 upvalues, 1 local, 2 constants, 0 functions 1 [3] GETGLOBAL 1 -1 ; print 2 [3] LOADK 2 -2 ; "1" 3 [3] MOVE 3 0 4 [3] CALL 1 3 1 5 [4] RETURN 0 1
local f = function() end
CLOSURE(Local('f'), f-index)
SEQUENCE( 	CLOSURE(Reg(0), f-index), 	MOVE(Local('f'), Reg(0)) )
function(...) 			local args = {...} 			for _,fstruct in ipairs(funcs) do 				local n,f = unpack(fstruct) 				-- we call the function with the next largest. 				if #args <= n then 					return f(unpack(args)) 				end 			end 			-- if we ever reach this point, just use the last function 			funcs[#funcs][2](unpack(args)) 		end