int CLuaFunctionDefs::XMLNodeSetAttribute ( lua_State* luaVM )
{
    // pNode, Attribute Name, Value
    CXMLNode* pNode = NULL;
    SString strAttributeName = "";
    SString strAttributeValue = "";
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );
    argStream.ReadString ( strAttributeName );
    argStream.ReadString ( strAttributeValue, "" );

    if ( !argStream.HasErrors ( ) )
    {
        if ( pNode )
        {
            // Are we going to set it to a value?
            if ( argStream.NextCouldBeString( -1 ) )
            {
                // Write the node
                CXMLAttribute* pAttribute = pNode->GetAttributes ().Create ( strAttributeName );
                if ( pAttribute )
                {
                    pAttribute->SetValue ( strAttributeValue );

                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
            else
            {
                // Delete the attribute if it exists
                CXMLAttribute* pAttribute = pNode->GetAttributes ().Find ( strAttributeName );
                if ( pAttribute )
                {
                    delete pAttribute;

                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}