util.TableToKeyValues

From GMod Wiki

Jump to: navigation, search
Function
Syntax util.TableToKeyValues( Table tab )
Where is this used?
Description:
Returns a table formatted in a key-value style string.
Returns: String
Part of Library: Util
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Util.TableToKeyValues]Util.TableToKeyValues [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionThis example format the table ready for output to a file.
Used onNewerShared.png
Code
local my_table = {}
my_table["health"] = 123.3
my_table["name"] = "Billy"
my_table["extra"] = {}
my_table["extra"]["param1"] = 234;
my_table["extra"]["param2"] = "Balloon";
my_table["extra"]["param3"] = tostring(true);
my_table["extra"]["param4"] = true;
 
Msg( util.TableToKeyValues(my_table) )
Output"Out"

{

"health" "123.3"
"name" "Billy"
"extra"
{
"param1" "234"
"param2" "Balloon"
"param3" "true"
}
}


Note the fact that my_table["extra"]["param4"] just disappears. Use tostring() like shown with "param3" to put booleans in the table.

Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox