Small question about functions. How do I get a function like string.find(), which outputs the end and beginning places of characters in a string as two numbers, to only return the beginning value? I don’t care about the last one only the first, but I have no idea how to separate them.
local start,_ = string.find(BlahBlahBlah)
got it, and _ would be the place I put the position of the returned value?
[s]also, another small one, if I have this:
local string=abc if string.StartWith(string, "ab") then print("oy vey fuker") else print("i have no idea what im doing") end
would I need to have something after the function on the ‘if’ line telling it to do that if it returns true, or does it automatically assume true means continue?[/s]
nevermind, checked the LUA users manual, can’t use return anywhere but the end of a block or something like that. thanks for the replies, leaving open for a minute just in case im wrong
_ is the endpos, we set it to _ since we don’t care about it.
return is used to stop the current block and eventually, if it is in a function, return data. In your case, when you run string.StartWith() StartString will return true or false.
[editline]7th November 2014[/editline]
I think you don’t even have to set it, try removing ,_ to see if it works properly.
ohhh I see. Also I think if it returns multiple variables and you only have one variable to cache them, they’re both stored in that variable’s name
but thanks I get it now, if there are multiple variables I can cache them and separate the names I want to assign each of them with commas in the order they are returned
thanks again: solved