util.KeyValuesToTable

From GMod Wiki

Jump to: navigation, search
Function
Syntax util.KeyValuesToTable( String text )
Where is this used?
Description:
Returns a table formatted in a key-value style string.
Returns: Table
Part of Library: Util
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Util.KeyValuesToTable]Util.KeyValuesToTable [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_string = [["0"
{
	"health"       "123.3"
	"name"         "Billy"
	"extra"
	{
		"param1"    "234"
		"param2"    "Balloon"
		"param3"    "true"
	}
}]]
 
my_table = util.KeyValuesToTable( my_string ) 
Output
 
my_table["health"] == 123.3
my_table["name"] == "Billy"
 
my_table["extra"]["param1"] == 234
my_table["extra"]["param2"] == "Balloon"
my_table["extra"]["param3"] == "true" -- NOT boolean value true. 
                             --Use util.tobool() to convert it to a boolean.
 
 


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox