Posted 28 July 2013 - 11:49 AM
i accidentally start this post so how do i delete this topic??
there is no delete button
there is no delete button
local a = 8
local function debug()
local varname = read() -- type "a"
print(tostring(getfenv(2)[varname])) -- will print 8
end
if expression then
-- do something if expression was true
else
-- do something if expression was false
end
nil and false in the expression evaluate false, anything apart from those evaluates true.I think so if statement is my fault and i will change question how do i call function from string with setfenvQuestion #1: WHAT? Sorry, the question makes no sense.
Question #2: getfenv and string indices:local a = 8 local function debug() local varname = read() -- type "a" print(tostring(getfenv(2)[varname])) -- will print 8 end
Question #3: IF statement doesn't work like that - it works like this:nil and false in the expression evaluate false, anything apart from those evaluates true.if expression then -- do something if expression was true else -- do something if expression was false end
I think so if statement is my fault and i will change question how do i call function from string with setfenv
Don't post a new question on a topic. The 3-post-thresold is not there for nothing.You need to supply it fuel unless you are in creative. Put fuel in its inventory and run refuel <amount>.
As I've already mentioned:I think so if statement is my fault and i will change question how do i call function from string with setfenv
local fenv = getfenv() -- gets the function environment table
local function debug()
local name = read()
print(fenv[name])
end