What does "function placement.new()" do?

Im not sure what the .new does? This is a module script and i’ve never seen this before because im new to scripting. Can someone please explain?

local placement = {}

--Constructor Variables
local GRID_SIZE
local ITEM_LOCATION
local ROTATE_KEY
local TERMINATE_KEY

--Constructor function
function placement.new(g, objs, r, t)
	local data = {}
	local metaData = setmetatable(data, placement)
	
	GRID_SIZE = g
	ITEM_LOCATION = objs
	ROTATE_KEY = r
	TERMINATE_KEY = t
	
	data.grid = GRID_SIZE
	data.itemlocation = ITEM_LOCATION
	data.rotatekey = ROTATE_KEY
	data.terminatekey = TERMINATE_KEY
	
	return data
end

return placement

.new (you can use colons too for self) is just the name of the function and placement is there because it has to get added to the table

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.