function A()
B()
end
function B()
end
i assume something like this would not work because of sequencing? or would it? would i have to define function B() first?
function A()
B()
end
function B()
end
i assume something like this would not work because of sequencing? or would it? would i have to define function B() first?
I believe you have to define it first. I could be wrong though.
Maybe this would help
define function B() first then you can potentially call function B() from function A()
function B()
end
function A()
B()
end
You shouldn’t have to define it first? As it’s not a local function, so sequence doesn’t matter I believe.
This works:
function A()
B()
end
function B()
print("B printed")
end
A()
I just wanted to add on that recursion, a function calling upon itself as a function, is possible as long as it can be calculated. For example:
function calculate(number)
if number + 2 == 12 then -- if the inputted number + 2 is 12 then we cool
print("nice, we got twelve")
else -- if not, try again using this function so we don't gotta retype all that nasty code
print("trying again...")
calculate(number+2)
end
end
calculate(2) -- will start calculating until it is 12