Call Function get boolean

Say I set a function and set certain situations for that function to return true / false… If I were to call it, and that function returned true, checking if it was true, it would go on with the if-statement, right?

I probably explained that bad, so here’s an example:

[lua]
function TestFunc( OurString )
if OurString == “true” then
return true
elseif OurString == “false” then
return false
end
end

–Some Code Later…
if TestFunc( “true” ) then
print( “The function returned true!” )
elseif TestFunc( “false” ) then
print( “The function returned false!” )
end
[/lua]

That should print “The function returned true!”, correct?

I’m asking this because for some reason it won’t work for me… Not because I don’t know if it would work.

[lua]
function ourFunc(boolString)
return (boolString == “true”);
end;

print(ourFunc(“true”))

– true
[/lua]

i tried it that way instead like this:

[lua]
function CheckIfStringIsOkay( OurString )
–Does check
StringOkay = “true”
end

function TestFunc( OurString )
return StringOkay
end

–Some Code Later…
if TestFunc( “true” ) == “true” then
print( “The function returned true!” )
else
print( “The function returned false!” )
end

[/lua]

And it keeps printing it’s false…

P.S. The functions and everything is just the theory of how it’s going on… It all works except the check at the end

You didn’t call CheckIfStringIsOkay()

It is called but in a complex way ( which I know I can optimize later ) and don’t feel like writing it out for the sake of an example

Are you sure? I just tried it with lua.org and it works fine.

It would probably be easier if I just give you the code I have…

[lua]
–cl_hud.lua
local Check = vgui.Create( “DButton”, Frame )
Check:SetPos( 10, 50 )
Check:SetSize( 137.5, 45 )
Check:SetText( “Check Name” )
Check.DoClick = function()
local nameargs = string.Explode( " ", Entry:GetValue() )
if #nameargs < 2 or #nameargs > 2 then image = “gui/silkicons/check_off” else
if SendRPNameCheck( Entry:GetValue() ) == “true” then
image = “gui/silkicons/check_on”
evolve:Notify( ply, evolve.colors.blue, “This name is available!” )
else
image = “gui/silkicons/check_off”
evolve:Notify( ply, evolve.colors.red, “This name has already been chosen!” )
end
end
end

–cl_init.lua
function RecieveRPNameCheck( um )
RPNameCheckValue = um:ReadString()
end
usermessage.Hook( “RecieveRPNameCheck”, RecieveRPNameCheck )
–Gets value back from my Check function in init.lua THAT WORKS.

function SendRPNameCheck( name )
RPNameCheckValue = nil
local name = string.Explode( " ", name )
RunConsoleCommand( “CheckNameForAvailability”, name[1], name[2] )
timer.Simple( 1, function()
RunConsoleCommand( “DebugNameCheck”, RPNameCheckValue ) – prints true
return RPNameCheckValue
end )
end
[/lua]