util.KeyValuesToTable

From Garry's Mod
Jump to: navigation, search
 util.KeyValuesToTable( )

Contents

Description

Converts a KeyValue string to a Lua table.

NOTE

Table keys will not repeat, see util.KeyValuesToTablePreserveOrder.

Arguments

string keyValues

The KeyValue string to convert.

Arguments

boolean usesEscapeSequences=false

If set to true, will replace \t, \n, \" and \\ in the input text with their escaped variants

Arguments

boolean preserveKeyCase=false

Whether we should preserve key case or not.

Returns

table

The converted table

Examples

Example

Example usage and output of this function. Note how there's only one "solid" key in the table despite the fact that input string contains multiple.

local ModelInfo = util.GetModelInfo("models/combine_gate_vehicle.mdl" )
PrintTable( util.KeyValuesToTable( ModelInfo.KeyValues ) )

Output:

editparams:
		rootname	=	
		totalmass	=	1
solid:
		damping	=	0
		index	=	4
		inertia	=	1
		mass	=	1
		name	=	Vehicle_Gate.Gate1_L
		rotdamping	=	0
		surfaceprop	=	metal
		volume	=	68522.8828125
Personal tools
Navigation