G.TableToKeyValues

From GMod Wiki

Jump to: navigation, search
Warning 64 severe.pngThis function is being moved to the util library once the GMod Beta 13 update becomes public



Function
Syntax TableToKeyValues( Table table )
Where is this used?
Description:
Converts a table into a key-value string.
Returns: String
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.TableToKeyValues]G.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( G.TableToKeyValues(my_table) )
Output
{
	"health"       "123.3"
	"name"         "Billy"
	"extra"
	{
		"param1"    "234"
		"param2"    "Balloon"
		"param3"    "true"
	}
}


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

Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox