catshy How do I cheat? Reputation: 0
Joined: 01 Feb 2019 Posts: 9
|
Posted: Fri Feb 01, 2019 2:51 am Post subject: Heroes of Might and Magic 3 (hota) |
|
|
Hello everybody!
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
So... does anyone have a code for make a list of available Heroes in game? Like
- Valesca
- Edric
... etc
|
|