This is for lua. I have no idea how functions work or what they are or what returns do.
In plain English, you can think of a function as something that takes some data
x as input, and gives you back some data
y as output. If the function has a name like foo, you would say foo takes x and returns y. What the function returns is simply the output.
They come from math (though in programming they do other things that aren’t mathematical too).
So a good example is some function named
doubleMyNumber(someNum). It takes
someNum and returns
someNum * 2.
You might see it defined as
return someNum * 2
Now, just defining a function doesn’t mean it does anything, you just describe what you want it to do when your program calls it. So later in your lua program you can write
myNum = doubleMyNumber(4)
What number do you think this code will print?
The twist is that in math functions take inputs and give outputs. In programming, you don’t actually have to have inputs and outputs (you can have the functions “do” other things).