Lua - Functions

Published 2014/03/05 by Admin in LUA

Create a function without parameters

function myFirstLuaFunction()

print("My first lua function was called")

end

Calling the function

myFirstLuaFunction()

 

Create a function with a return value

function mySecondLuaFunction()

return "string from my second function"

end

Calling the function

a=mySecondLuaFunction()

print(a)

 

Create a function with multiple parameters and multiple return values

function myFirstFunctionWithMultipleReturnValues(a,b,c)

return a,b,c,"My first lua function with multiple return values", 1, true

end

Calling the function

a,b,c,d,e,f = myFirstFunctionWithMultipleReturnValues(1,2 , "three")

print(1,b,c,d,e,f)


Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

my coding

This is a collection of all the coding gems I have found and would like to share with the world!