Calling predefined functions

I couldn’t figure out any other way to word the title, so excuse that.

[lua]concommand.Add( “deathdoom_callfunc”, aFunction )[/lua]

The above code would call a predefined function. I want to know how I would call a function… within a function.
Hard for me to explain in text, so allow me to do so in code.

[lua]
function aFunction ()
print( “aFunction has been called!” )
end

if A > B then
CALLFUNCTION aFunction ()
end
[/lua]

So, I’d be calling a predefined function, as opposed to:

[lua]
if A > B then
function aFunction ()
print( “aFunction has been called!” )
end
end
[/lua]

To call a function you just use the name of the function, and to signal that it’s a function you give the arguments (parentheses). For example,

[lua]if A > B then
aFunction()
end[/lua]

Also you can call them pretty much anywhere.

[lua]
function a( n )
return n*2
end

b = 3
print( b+ a( b ) )
[/lua]

edit : :smile:

I think you mean “return n*2”. :stuck_out_tongue:
…Unless you recursively call the function, and then that’s just having fun with loops.

It’s okay, what Entoros posted fits what I need just perfectly.