• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

words insert to table

Dominik ms

Member
Joined
Jan 20, 2010
Messages
424
Reaction score
6
i have message "lol34"
i want this insert to a table

table = {"l", "o", "l", "3", "4"}

how to do this??
 
PHP:
function onUse(cid, item, pos, itemEx, topos)
local new = {}
local str = "43534"
	for i = 1, str:len() do
		table.insert(new, str[i])
	end
	doCreatureSay(cid, new[1])
end

table is empty ;/
 
Code:
function onUse(cid, item, pos, itemEx, topos)
local new = {}
local str = "43534"
    for i = 1, str:len() do
        table.insert(new, str[i])
    end
    for _, v in ipairs(new) do
	    doCretureSay(cid, 0x0D, v)
	end
end
 
i'm not sure that strings in LUA has operator[] :/
u can try this:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local new = {}
	local str = "asdasdewe"
	local p = str:find("*%s")
	while p do
		table.insert(new, p)
	end
	doCreatureSay(cid, 0x0D, table.concat(new, ", "))
	return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local new = {}
	local str = "asdasdewe"
	local p = str:find("*%s")
	while p do
		table.insert(new, p)
	end
	doCreatureSay(cid, 13, table.concat(new, ", "))
	return true
end
 
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local new = {}
	local str = "asdasdewe"
	local p = str:find("*%s")
	while p do
		table.insert(new, p)
	end
		say(cid, table.concat(new, ", "), TALKTYPE_SAY)
	return true
end

but result is Dominik [10]:
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition) 
	local str, t, i = 'asdasdasd', {}
	while i < str:len() do
		table.insert(t, str:sub(i, i + 1))
		i = i + 1
	end
	doCreatureSay(cid, table.concat(t, ', '), TALKTYPE_SAY)
	return true
end
 
not work

@
i thing you dont understand me
look
have an word example "LOL"
i want cut wirst letter "L" i print it
example table[1]
for letter "O" == table[2]

or somethink like this
 
Back
Top