Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


function from string???

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Oct 22, 2018 8:34 am    Post subject: function from string??? Reply with quote

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.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon Oct 22, 2018 10:27 am    Post subject: Reply with quote

http://lua-users.org/wiki/StringLibraryTutorial
Quote:
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.

_________________
Back to top
View user's profile Send private message Visit poster's website
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Oct 22, 2018 1:13 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites