Garry's Mod Wiki


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


Converts a Valve KeyValue string (typically from util.TableToKeyValues) to a Lua table.

Due to how tables work in Lua, keys will not repeat within a table. See util.KeyValuesToTablePreserveOrder for alternative.


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)


1 table
The converted table


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 ) )
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