Garry's Mod Wiki

util.KeyValuesToTable

table util.KeyValuesToTable( string keyValues, boolean usesEscapeSequences = false, boolean preserveKeyCase = false )

Description

Converts a KeyValue string to a Lua table.

Table keys will not repeat, see util.KeyValuesToTablePreserveOrder.

Arguments

1 string keyValues
The KeyValue string to convert.
2 boolean usesEscapeSequences = false
If set to true, will replace \t, \n, " and \ in the input text with their escaped variants
3 boolean preserveKeyCase = false
Whether we should preserve key case (may fail) or not (always lowercase)

Returns

1 table
The converted table

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

Page Links


Special Pages


Wikis

?

Render Time: 94ms

DB GetPage 49
Generate Html 15
SaveChanges (1) 10
Render Body 0
Render Sidebar 17