Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[SOLVED] Calling a function without parenthesis?

Hi there! So I found a script somewhere in the toolbox and decided to see how it is written. However in the script I saw that some functions are called without parenthesis and I don't get how. Can someone explain? Any help appreciated :)

It is a Module Script that looks something like this:

local module = {}

local function disablePlacement(plane) -- Function 1
	if (currentPlane) then
		renderConnection:disconnect()
		renderConnection = nil
		currentPlane = nil
		module.currentPlane = nil
		currentEvent:Destroy()
		currentEvent = nil	
		
		if (currentTexture) then
			currentTexture:Destroy()
			currentTexture = nil
		end
		
		for i = 1, #currentObjects do
			local object = currentObjects[i]
			object.model = nil
			currentObjects[i] = nil
		end
		
		unbindInputs()
	end
end

local function setLoading(plane, isLoading) -- Function 2
	if (plane.loading == isLoading) then
		return
	end
	
	plane.loading = isLoading
	
	if (plane == currentPlane) then	
		if (isLoading) then
			for i = 1, #currentObjects do
				setState(currentObjects[i], states.loading)
			end
		else
			for i = 1, #currentObjects do
				setState(currentObjects[i], states.neutral, true)
			end
			
			obstacleCollision()
		end
	end
end


module.new = function(base, obstacles, grid)
	local plane = {}
	plane.base = base
	plane.obstacles = obstacles
	plane.position = base.Position
	plane.size = base.Size
	
	if (math.floor(.5 + plane.size.X/grid) % 2 == 0) then
		plane.offsetX = -grid/2
	else
		plane.offsetX = 0
	end
	
	if (math.floor(.5 + plane.size.Z/grid) % 2 == 0) then
		plane.offsetZ = -grid/2
	else
		plane.offsetZ = 0
	end
	
	
	plane.stateEvent = Instance.new("BindableEvent")
	plane.stateChanged = plane.stateEvent.Event	
	
	plane.grid = grid
	plane.enable = enablePlacement
	plane.disable = disablePlacement -- Calling function 1 without parenthesis??
	plane.rotate = rotate
	plane.place = place
	plane.setLoading = setLoading -- Calling function 2 without parenthesis??
	
	return plane
end

module.setLoading = setLoading
module.currentPlane = false

return module

NOTE: These are only some parts of the script, not the full version.

Again, any help will be appreciated :)

2 comments

0

My question here is that it doesn't? Please explain further

0

Sorry i see now

1 answer

✓ Accepted answer

It doesn't call them, it makes it so that the variable is the function I'm pretty sure. I might be wrong.

1 comment

0

Ah thanks mate, didn't code in roblox for a long time haha

This discussion is preserved as it was. New answers, comments, and votes are closed.