gettok
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function splits a string using the given separating character and returns one specified substring.
Syntax
string gettok ( string text, int tokenNumber, string / 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, and so on).
- / int separatingCharacter: MISSING_PARAM_DESC
Returns
- string: value
Returns a string containing the token if it exists, false otherwise.
Code Examples
shared
This example retrieves the startskin and endskin for spawning a player from a string of two numbers "a,b"
-- 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 strings ("20" and "30" in this case)local startskin = gettok ( skins, 1, ',')local endskin = gettok ( skins, 2, ',' )-- Get a random skin in the rangelocal skin = math.random ( tonumber(startskin), tonumber(endskin) )See Also
Utility Functions
- addDebugHook
- bitAnd
- bitArShift
- bitExtract
- bitLRotate
- bitLShift
- bitNot
- bitOr
- bitReplace
- bitRRotate
- bitRShift
- bitTest
- bitXor
- createTrayNotification
- debugSleep
- decodeString
- deref
- downloadFile
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getFPSLimit
- getKeyboardLayout
- getLocalization
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getProcessMemoryStats
- getRealTime
- getServerIp
- getTickCount
- getTimerDetails
- getTimers
- gettok
- getUserdataType
- getVersion
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTimer
- isTimerPaused
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- ref
- removeDebugHook
- resetTimer
- setClipboard
- setDevelopmentMode
- setFPSLimit
- setTimer
- setTimerPaused
- setTransferBoxVisible
- setWindowFlashing
- sha256
- showCol
- showSound
- split
- teaDecode
- teaEncode
- tocolor
- toJSON
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub