Can someone explain returns to me plz? The wiki makes no sense to me.
Returning is a way to get info out of a function. Let me give you an example:
function Add(a,b) return a+b end
This will take two numbers and add them together, then return the result.
So if we do this:
Add(1,3)
Lua will read it as '4'
Here's a full example:
function Add(a,b) return a+b end print(Add(2,5)) --this will print 7
You can also return booleans
and strings
. Returning is useful for functions that 'check' whether something is true, or return a string based on user input.