Posted: Mon Oct 22, 2018 8:34 am Post subject: function from string???
Got this:
Code:
-- pc is just filled with this sorta stuff
pc = [[
==(1) In-Game?
D09E8A04 00300000
Note: This stops FF12 from reporting corrupted save when trying to load
cheats into a game.
==(3) Item/Ability/Gambit IDs
Too long to include here so will create a separate file.
==(4) RAW Codes
Will do final checks before adding list
==(4.1) Max Gil
D09E8A04 00300000
2054C008 05F5E0FF
==(4.2) All Characters
...
function BuildPatchList()
local text = false
local code = ""
local note = ""
local mr = cet.createMemoryRecord()
local tmp
mr.setDescription('Patch Codes')
pc = pc:gmatch(".*\n")
-- Reports error here saying pc is a function
for line,l in pairs(pc) do
tmp = l:gmatch("%S+")
if #tmp == 0 then
if text ~= false then
Patch(mr,text,code)
end
text = false
code = ""
note = ""
elseif text == false then
text = l
elseif #l == 17 then
code = code .. l
if #tmp == 2 then
-- Make sure it is a code line
if #(tmp[1]) == 8 and
#(tmp[2]) == 8 then
code = code .. l
note = ""
else
note = note .. l
end
else
note = note .. l
end
else
note = note .. l
end
end
end
Placed a comment exactly where the error occurs and I don't understand how to fix it _________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
string.gmatch(s, pattern)
s:gmatch(pattern)
This returns a pattern finding iterator. The iterator will search through the string passed looking for instances of the pattern you passed.
> for word in string.gmatch("Hello Lua user", "%a+") do print(word) end
Hello
Lua
user
"gmatch" returns an iterator (function), change your for loop to work with an iterator. _________________
Thanks :)
Helped me fix another problem I didn't even know about, had to make a custom iterator for lines though which erks me because it doesn't treat regexp as the standard indicates _________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum