Howto: expand variables

Share your scripts and packages with other Mudlet users.
Post Reply
eraldo
Posts: 43
Joined: Sun Jul 12, 2009 1:25 am

Howto: expand variables

Post by eraldo »

Example:

Global variable:
MyNumber = 10

function:

Code: Select all

        testFunction(a, b)
            local VariableNameString = a .. b
            local value = tonumber( VariableNameString )
            echo( value )
        end


Function call:
testFunction( "My", "Number" )

Result:
10

Xinael
Posts: 1
Joined: Thu Nov 26, 2009 8:00 pm

Re: Howto: expand variables

Post by Xinael »

Or:

echo(_G["My" .. "Number"])

_G is the global table.

Post Reply