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

fixing string.find

Started by tatskaari, 19 April 2013 - 07:12 AM
tatskaari #1
Posted 19 April 2013 - 09:12 AM
Hi,
Using string.find on the result of string.sub will return the index of the original string, not the string you passed in. However, if you concatenate the result from sub with "" then it will work. After spending 3 hours trying to debug my code I would have very much appreciated this, albeit hacky, fix implemented.
Thanks, Tats
remiX #2
Posted 19 April 2013 - 10:36 AM
Yes, "" does fix it. Most people know that. You should have asked in Ask a Pro :P/>

I remember reading documention about the string api which stated something about adding "" onto string.find … can't find it though :\
Lyqyd #3
Posted 19 April 2013 - 11:46 AM
No, that wouldn't have been in any official documentation. This is a bug in LuaJ's string library specifically.

The devs have previously stated that this will be fixed as a side effect of the likely eventual move away from LuaJ, so I'll lock this.