Garry's Mod Wiki

Garry's Mod Wiki

  any util.StringToType( string str, string typename )

Description

Converts a string to the specified type.

This can be useful when dealing with ConVars.

Arguments

1 string str
The string to convert
2 string typename
The type to attempt to convert the string to. This can be vector, angle, float, int, bool, or string (case insensitive).

Returns

1 any
The result of the conversion, or nil if a bad type is specified.

Example

Creates a vector from a string representation.

local vec = util.StringToType("5 6 75", "Vector")
Output: A vector with components (5, 6, 75)

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 twice a day. Edits and history are not available.

Last Parsed: Loading...