External modules with variable function names

Hi guys

I have a situation where different things happen depending on what’s pressed and was wondering if there was any way to do the following:

  
local variable = VARIABLEVALUE  
  
local myFunction = functions.VARIABLEVALUE  
  

Thanks!

[import]uid: 40538 topic_id: 16582 reply_id: 316582[/import]

Assuming ‘functions’ is a table that has all of your functions stored as dictionary indices, you can do that, but your syntax is a little off.

It would be something like:

local variable = "variablevalue"local myFunction = functions[variable][/code] [import]uid: 52430 topic_id: 16582 reply_id: 61979[/import]

unless you set the metatable of that table functions to return the function as default so that you can use the function.VARIABLENAME instead of functions[VARIABLENAME]

have a look at something similar at http://howto.oz-apps.com/2011/09/making-your-own-logic-language.html

you can change the default functionality of the table and thereby reference them in wonderous ways other than the standard.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16582 reply_id: 62007[/import]

Thanks guys! I’ll look into those options and see what I can come up with.
JayantV, I’ve briefly read up on your other metatables tutorial, but it sounds really confusing =/.
I will nevertheless try it!
Cheers [import]uid: 40538 topic_id: 16582 reply_id: 62023[/import]

Well, if you want to do things that are *non* standard, then you have to be prepared to venture into the areas that as you have put it *confusing* or *complicated* if it was simple, then why would it be non standard?

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16582 reply_id: 62024[/import]

@Jonathan I want to thank you for pointing me in the right direction.

@JayantV I would like to thank you for your words of encouragement.
Putting the above combination together I have worked out what I needed to do and it works amazingly well! Whilst it may seem trivial I am pleased with myself ;).
Thanks again both of ya :smiley: [import]uid: 40538 topic_id: 16582 reply_id: 62183[/import]