Garry's Mod Wiki

Garry's Mod Wiki

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

Description

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.

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

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...