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 


Heroes of Might and Magic 3 (hota)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
catshy
How do I cheat?
Reputation: 0

Joined: 01 Feb 2019
Posts: 1

PostPosted: Fri Feb 01, 2019 2:51 am    Post subject: Heroes of Might and Magic 3 (hota) Reply with quote

Hello everybody! Smile

Im trying to understand Lua scripts, and I found one example on this forum, but it doesn't work for me. Code should print a list of Heroes. Code:

Code:

local function getStructureIDByName(name)
  local lname = name:lower()
  local casematch = nil
  local count = getStructureCount()-1
  for i=0, count do
    local struct = getStructure(i)
    if struct.Name == name then return i
    elseif struct.Name:lower() == lname then
      if casematch == nil then casematch = i
      else return nil, "more than one structure matches when ignoring case"
      end
    end
  end
  if casematch then return casematch else return nil, ("No structure with the name '%s' exists"):format(name) end
end


local function getStructureByName(name)
  local id, errmsg = getStructureIDByName(name)
  if not id then
    return nil, errmsg
  else
    return getStructure(id)
  end
end


local heroesStruct = getStructureByName('Heroes')

for i=0, heroesStruct.Count-1 do
  local element = heroesStruct.getElement(i)
  local new = ('%d:+Heroes.%s'):format(element.Offset, element.Name)

  print(new)
end


When I execute I'm getting error:

Code:
Error:[string "--for i=1,10 do
..."]:40: attempt to index a nil value (local 'heroesStruct')



Maybe just this structrure doesn't exists, but how to get a list of all available structures?


Edit:

Well, ok, I get a list of structs - I thought it would be more detailed - like array with all important data Smile

So... does anyone have a code for make a list of available Heroes in game? Like

- Valesca
- Edric
... etc
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 Lua Scripting 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