Translated by Google
The cause is always to return a value of 0 when counting the number of power switches, and then found that the function string.find problem, sometimes can not return the correct result when encountering a hyphen
[0.17.60]The lua function string.find cannot return the correct result
Re: [0.17.60]The lua function string.find cannot return the correct result
You are using poor syntax,
You need to escape the `-` with `%`
So like this:
Lua Documentation: https://www.lua.org/pil/20.1.html https://www.lua.org/pil/20.2.html
You need to escape the `-` with `%`
So like this:
Code: Select all
/c local a = string.find("power-switch", "power%-switch") game.print(a)
Re: [0.17.60]The lua function string.find cannot return the correct result
This is really too embarrassing.
I have not learned the lua grammar,I will only imitate the example on the wiki.
I am sorry for wasting your time for this low-level problem.
I have not learned the lua grammar,I will only imitate the example on the wiki.
I am sorry for wasting your time for this low-level problem.