Gettok: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
*'''text:''' The string that should be split | *'''text:''' The string that should be split | ||
*'''tokenNumber:''' Which token should be returned (1 for the first, 2 for the second, ..) | *'''tokenNumber:''' Which token should be returned (1 for the first, 2 for the second, ..) | ||
*'''separatingCharacter:''' The ASCII number | *'''separatingCharacter:''' The [[ASCII|ASCII number]] representing the character you want to use to separate the tokens | ||
===Returns=== | ===Returns=== |
Revision as of 12:08, 20 October 2007
This function splits a string using the given seperating character and returns one part as a string.
Syntax
string gettok ( string text, int tokenNumber, int separatingCharacter )
Required Arguments
- text: The string that should be split
- tokenNumber: Which token should be returned (1 for the first, 2 for the second, ..)
- separatingCharacter: The ASCII number representing the character you want to use to separate the tokens
Returns
Returns the token if it exists, false otherwise.
Example
Click to collapse [-]
ServerThis example retrieves the startskin and endskin for spawning a player
-- Put the string with the skins in a variable. Normally you would read it from a .map file or something. local skins = "20,30" -- Get the startskin and endskin (20 and 30) local startskin = gettok ( skins, 1, 44 ) local endskin = gettok ( skins, 2, 44 ) -- Get a random skin of the range local skin = randInt ( tonumber(startskin), tonumber(endskin) )
See Also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub