util.KeyValuesToTablePreserveOrder

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

Contents

Description

Similar to util.KeyValuesToTable but it also preserves order of keys.

Arguments

string keyvals

The key value string

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 output table

Examples

Example

Example usage and output of this function. Note how there are multiple entries where they key is "solid", just like in the input string.

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

Output:

1:
		Key	=	solid
		Value:
				1:
						Key	=	index
						Value	=	0
				2:
						Key	=	name
						Value	=	Vehicle_Gate.Gate2_L
				3:
						Key	=	mass
						Value	=	1
				4:
						Key	=	surfaceprop
						Value	=	metal
				5:
						Key	=	damping
						Value	=	0
				6:
						Key	=	rotdamping
						Value	=	0
				7:
						Key	=	inertia
						Value	=	1
				8:
						Key	=	volume
						Value	=	68522.9296875
2:
		Key	=	solid
		Value:
				1:
						Key	=	index
						Value	=	1
				2:
						Key	=	name
						Value	=	Vehicle_Gate.Gate3_R
....
Personal tools
Navigation