I want to use the functions I located in my table. How do I do that?
Using tabled functions
Started by Doyle3694, Sep 26 2012 08:31 PM
3 replies to this topic
#1
Posted 26 September 2012 - 08:31 PM
#2
Posted 26 September 2012 - 08:42 PM
same as any other functions. ().
local function f1()
print("Hello world!")
end
local function f2(name)
print("Hello, "..name.."!")
end
local myFunctionTable= {
f1=f1,
f2=f2,
}
myFunctionTable.f1()
myFunctionTable.f2("bob")
#3
Posted 26 September 2012 - 08:46 PM
The advantage is that you can also use a variable as index
key=read() myFunctionTable[key]()
#4
Posted 26 September 2012 - 08:47 PM
oh () at the end... derp, thanks
/>
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











