PDA

View Full Version : odd lua string issue



yonu
October 15th, 2015, 05:26 PM
ok this may seem odd but I can get this simple line to work with G5 scripting but not G6

all I get is nil for the variables.

the code is



print (rawpwr)
--print(string.gsub(rawpwr, "%.", "%\n"))
--linepwr = string.gsub(rawpwr, "%.", "%\n")

_, _, pwrtime, pwrpercentage = string.find(rawpwr, "state:\s(.-)\s.-percentage:\s(.-)")
print("state ", pwrstate)
print("percent ",pwrpercentage)


rawpwr is


state: fully-charged percentage: 100%



I am a bit confused as the same code works in a G5 scripting action hopinh I am simply overlooking something that changed in the newer version of Lua

Thanks,
Yonu

yonu
October 16th, 2015, 12:45 PM
please disregard I just got it figured out I am an idiot i was using \s when I should have been using %s

Yonu

Ron
October 16th, 2015, 01:17 PM
yes that is the ticket, sorry I didn't see you question earlier.