Jump to content

xmlNodeGetAttribute with booleans?


zixxonx

Recommended Posts

Posted

Im making a shader panel/scoreboard columns panel and thats my xml file:

"true" carpaint="false" roadshine="false" killscol="true" deathscol="true" winscol="true">

That's good and it should work but i think those true and false are just strings, i did it

local shaderwater = xmlNodeGetAttribute(xmlFile,"shaderwater") 

then

outputChatBox(shaderwater) 

I should get error talking me about booleans but it shows the value also i must did it:

xmlNodeSetAttribute(xmlFile,"shaderwater",tostring(getElementData(player, "shaderwater"))) 

To save it properly. Can i change those strings too booleans or is there any other function to save booleans properly?

Posted
local shaderwater = xmlNodeGetAttribute(xmlFile,"shaderwater") == "true" and true or false 

This should convert strings to booleans.

Posted
function convertStringToBoolean ( str ) 
    local str = tostring ( string.lower ( str ) ) 
    if ( str == 'true' ) then 
        return true 
    elseif ( str == 'false' ) then 
        return false 
    end 
    return nil 
end 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...