Forum

> > CS2D > Scripts > Next number in string
Forums overviewCS2D overview Scripts overviewLog in to reply

English Next number in string

4 replies
To the start Previous 1 Next To the start

old Next number in string

Alistaire
User Off Offline

Quote
Is there a way to find the next number in a string? So I don't have to use message:sub at saycommands with awefully long ammounts of numbers?

My current sayfunction is like;

!func {value} {value} {value} {value} {value}

or

!func atme

old Re: Next number in string

Deleted User

Quote
function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end

use this

example:

1
2
local string = "Hello my name is David"
local t = totable(string)

t[1] = Hello
t[2] = my
t[3] = name
t[4] = is
t[5] = David

old Re: Next number in string

EngiN33R
Moderator Off Offline

Quote
user VADemon has written
@user Infinite Rain:
The computer says no! Doesn't work at lua demo. There's no totable() ?


Err, he specified the totable right above the code snippet? It's not enclosed in code tags, but it's there.

old Re: Next number in string

Deleted User

Quote
Yeah, sorry about that.
Code:

1
2
3
4
5
6
7
8
function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview