This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KaoS's profile picture

[SOLVED] String manipulation *was stupid question

Started by KaoS, 30 August 2012 - 09:36 AM
KaoS #1
Posted 30 August 2012 - 11:36 AM
Hey again, back already with another question, how do you select a certain character in a string, in vbs you can say
left(string,num)
and it will return num letters from the left. for example
left('hello world!',3)
would return 'hel'
and you can do the same for the right, using this you can build the following function (I will use lua syntax as you are familiar with it)

local function atloc(string,at,till)
return right(left(string,at+till),till)
end
and then you can say
atloc('hello world',2,3)
and it would return 'ell'

I need this for a game design but I don't know if there are any functions like this in LUA, I have checked the string manipulation area in the manual with no success
KaoS #2
Posted 30 August 2012 - 11:46 AM
haha, just found it… so blind

you use string.sub