My coding mentality derives from a PHP background. And manipulating variables is much more forgiving with PHP.
I am passing a variable, as a function parameter. No worries there.
function checkMeOut(var)
if( var == "heaven" ) then
print("bring a chair");
end
local lastVarPassed = var;
end
Notice I declare a variable at the end of the function, saving the last string passed. I do this for a few reasons, but mainly to work with a condition inside the function. The condition is supposed to check if the lastVarPassed is the same as the next var being passed.
So here is what I would normally do, in a PHP environment:
function checkMeOut(var)
--check if last var matches the current var
if( lastVarPassed ~= var ) then
print("that's a new value than before!");
end
if( var == "heaven" ) then
print("bring a chair");
end
local lastVarPassed = var;
end
From what I can see, that condition is never detected. I may be missing something, like declaring the lastVarPassed in the wrong place.
Can anyone see if I’m doing something weird with that if statement? [import]uid: 154122 topic_id: 27343 reply_id: 327343[/import]