Hi I'm here again.
I would like to know if it possible to crate a table that has functions associated with the keys.
At least I need a way to call different functions like in a switch-case but
I'm tring to do this using the tables to search the case.
This is a possible example of what I want to do (doesn't work):
test = "cane"
versi = {
cane = function bau()
gatto = function miao()
mucca = function mu()
}
function bau()
print "BAU BAU BAU"
end
function miao()
print "MIAO MIAO MIAO"
end
function mu()
print "MU MU MU"
end
versi[test]
tables with functions
Moderators: Shine, Insert_witty_name
Re: tables with functions
Heres what you do there are 2 ways of doing this.swordman wrote:Hi I'm here again.
I would like to know if it possible to crate a table that has functions associated with the keys.
At least I need a way to call different functions like in a switch-case but
I'm tring to do this using the tables to search the case.
This is a possible example of what I want to do (doesn't work):
test = "cane"
versi = {
cane = function bau()
gatto = function miao()
mucca = function mu()
}
function bau()
print "BAU BAU BAU"
end
function miao()
print "MIAO MIAO MIAO"
end
function mu()
print "MU MU MU"
end
versi[test]
Variable = { }
function Variable:Command(arg1,arg2)
end
or
Variable = {
Command = function (arg1, arg2)
end;
}