Difference between revisions of "Gkini"
Line 13: | Line 13: | ||
− | + | == Functions == | |
=== ReadInt === | === ReadInt === | ||
− | '''Definition:''' | + | '''Definition:'''<br> |
− | ReadInt(string section, string key, int default) - | + | ReadInt(string section, string key, int default) -> int value |
− | + | <br><br> | |
− | '''Description:''' | + | '''Description:''' <br> |
Read an integer from the given section and key | Read an integer from the given section and key | ||
− | + | <br><br> | |
− | '''Arguments:''' | + | '''Arguments:'''<br> |
− | '''section''' a section of the config file | + | '''section''' a section of the config file<br> |
− | '''key''' key within a section | + | '''key''' key within a section<br> |
'''default''' value to return if key not found | '''default''' value to return if key not found | ||
− | + | <br><br> | |
'''Returns:''' | '''Returns:''' | ||
− | + | <br><br> | |
− | '''Example:''' | + | '''Example:'''<br> |
− | + | <source lang="lua">gkini.ReadInt("Vendetta", "showhelpstring", 1) -> 0 -- showhelpstring is ccurrently set to 0</source> | |
− | + | <br><br> | |
=== ReadString === | === ReadString === | ||
− | '''Definition:''' | + | '''Definition:'''<br> |
− | ReadString(string section, string key, string default) - | + | ReadString(string section, string key, string default) -> string value |
− | + | <br><br> | |
− | '''Description:''' | + | '''Description:''' <br> |
Read a string from the given section and key | Read a string from the given section and key | ||
− | + | <br><br> | |
− | '''Arguments:''' | + | '''Arguments:'''<br> |
− | '''section''' a section of the config file | + | '''section''' a section of the config file<br> |
− | '''key''' key within a section | + | '''key''' key within a section<br> |
'''default''' value to return if key not found | '''default''' value to return if key not found | ||
− | + | <br><br> | |
'''Returns:''' | '''Returns:''' | ||
− | + | <br><br> | |
− | '''Example:''' | + | '''Example:'''<br> |
− | + | <source lang="lua">gkini.ReadString("Vendetta", "Username", "dude") -> "hans" -- get the default username from the config file</source> | |
− | + | <br><br> | |
=== WriteInt === | === WriteInt === | ||
− | '''Definition:''' | + | '''Definition:'''<br> |
− | WriteInt(string section, string key, int value) - | + | WriteInt(string section, string key, int value) -> nil |
− | + | <br><br> | |
− | '''Description:''' | + | '''Description:''' <br> |
Write an integer to the given section and key | Write an integer to the given section and key | ||
− | + | <br><br> | |
− | '''Arguments:''' | + | '''Arguments:'''<br> |
− | '''section''' a section of the config file | + | '''section''' a section of the config file<br> |
− | '''key''' key within a section | + | '''key''' key within a section<br> |
'''value''' value of a key as an integer | '''value''' value of a key as an integer | ||
− | + | <br><br> | |
'''Returns:''' | '''Returns:''' | ||
− | + | <br><br> | |
− | '''Example:''' | + | '''Example:'''<br> |
− | + | <source lang="lua">gkini.WriteInt("Vendetta", "showhelpstring", 1) -- change the showhelpstring option to 1</source> | |
− | + | <br><br> | |
=== WriteString === | === WriteString === | ||
− | '''Definition:''' | + | '''Definition:'''<br> |
− | WriteString(string section, string key, string value) - | + | WriteString(string section, string key, string value) -> nil |
− | + | <br><br> | |
− | '''Description:''' | + | '''Description:''' <br> |
Write a string to the given section and key. String length is limited to 763 characters. | Write a string to the given section and key. String length is limited to 763 characters. | ||
− | + | <br><br> | |
− | '''Arguments:''' | + | '''Arguments:'''<br> |
− | '''section''' a section of the config file | + | '''section''' a section of the config file<br> |
− | '''key''' key within a section | + | '''key''' key within a section<br> |
'''value''' value of a key as a string | '''value''' value of a key as a string | ||
− | + | <br><br> | |
'''Returns:''' | '''Returns:''' | ||
− | + | <br><br> | |
− | '''Example:''' | + | '''Example:'''<br> |
− | + | <source lang="lua">gkini.WriteString("Vendetta", "Username", "dude") -- change the Username option to dude</source> | |
− | + | <br><br> | |
[[Category:Tables]] | [[Category:Tables]] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 18:54, 20 November 2010
These are functions to manipulate the games config file config.ini.
The format of the file looks like this:
[section]
key=value
.
.
value can either be a string or an integer all identifiers are case sensitive
Functions
ReadInt
Definition:
ReadInt(string section, string key, int default) -> int value
Description:
Read an integer from the given section and key
Arguments:
section a section of the config file
key key within a section
default value to return if key not found
Returns:
Example:
gkini.ReadInt("Vendetta", "showhelpstring", 1) -> 0 -- showhelpstring is ccurrently set to 0
ReadString
Definition:
ReadString(string section, string key, string default) -> string value
Description:
Read a string from the given section and key
Arguments:
section a section of the config file
key key within a section
default value to return if key not found
Returns:
Example:
gkini.ReadString("Vendetta", "Username", "dude") -> "hans" -- get the default username from the config file
WriteInt
Definition:
WriteInt(string section, string key, int value) -> nil
Description:
Write an integer to the given section and key
Arguments:
section a section of the config file
key key within a section
value value of a key as an integer
Returns:
Example:
gkini.WriteInt("Vendetta", "showhelpstring", 1) -- change the showhelpstring option to 1
WriteString
Definition:
WriteString(string section, string key, string value) -> nil
Description:
Write a string to the given section and key. String length is limited to 763 characters.
Arguments:
section a section of the config file
key key within a section
value value of a key as a string
Returns:
Example:
gkini.WriteString("Vendetta", "Username", "dude") -- change the Username option to dude