I cannot seem to find any other online help about creating a table which contains functions which are multiline. For example, here is a snippit of code from the lua wiki.
action = {
[1] = function (x) print(1) end,
[2] = function (x) z = 5 end,
["nop"] = function (x) print(math.random()) end,
["my name"] = function (x) print("fred") end,
}
I want to do something like this:
action = {
[1] = function blah()
more code here
end
[2] = function blahblah()
more code here
end
}
So how can I do so?
action = {
[1] = function (x)
print(1)
end,
[2] = function (x)
z = 5
end,
["nop"] = function (x)
print(math.random())
end,
["my name"] = function (x)
print("fred")
end,
}
You are free to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With