Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

necrolua.get returns wrong type (c_Familiar) #5

Open
pancelor opened this issue Sep 2, 2019 · 1 comment
Open

necrolua.get returns wrong type (c_Familiar) #5

pancelor opened this issue Sep 2, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@pancelor
Copy link
Collaborator

pancelor commented Sep 2, 2019

Here's the full text of my mod:

necrolua.hook("c_Player::p_UseBomb", function(func, self)
  print "c_Player::p_UseBomb"

  local cls = necrolua.get("c_Enemy")
  local obj = cls:m_GetRandomEnemy()
end)

I load the game and press my bomb hotkey (in the lobby, not that it should matter), and necrolua.exe crashes:

c_Player::p_UseBomb
[←[33mNecroLuaAPI.dll←[0m][←[32mLua←[0m] nl_luainit.lua:424: nl_get :: cast("c_Familiar*", 11)
mods\0luatest\lua\init.lua:5: 'struct c_Familiar' has no member named 'm_GetRandomEnemy'
stack traceback:
        mods\0luatest\lua\init.lua:5: in function <mods\0luatest\lua\init.lua:1>
        [C]: in function 'xpcall'
        nl_luainit.lua:451: in function <nl_luainit.lua:450>
[←[33mNecroLuaAPI.dll←[0m] nl_payload.c:150: Mod API finalized.
[NecroLua.exe] nl_launcher.c: 58: Done with exit code 0x00000001

Note in particular: 'struct c_Familiar' has no member named 'm_GetRandomEnemy'. This is strange; did necrolua.get("c_Enemy") return a c_Familiar instead of a c_Enemy?

Changing necrolua.get("c_Enemy") to necrolua.get("c_Player") results in the exact same error (still c_Familiar)

@pancelor
Copy link
Collaborator Author

pancelor commented Sep 2, 2019

Oh, this is strange; I left the hook alone but added a necrolua.enumsymbols call earlier in the program, and now instead of complaining about c_Familiar, the program is complaining about c_XMLNode:

Full text of mod:

print ""
print "listing"
print ""

necrolua.enumsymbols("c_Enemy*", function(symbol_info)
  print(symbol_info.NameLuaStr)
  return true
end)

print ""
print "done"
print ""

necrolua.hook("c_Player::p_UseBomb", function(func, self)
  print "c_Player::p_UseBomb"

  local cls = necrolua.get("c_Enemy")
  local obj = cls:m_GetRandomEnemy()
end)

This lists 145 c_Enemy* symbols on startup. I press my bomb hotkey, and necrolua.exe crashes:

c_Player::p_UseBomb
[←[33mNecroLuaAPI.dll←[0m][←[32mLua←[0m] nl_luainit.lua:424: nl_get :: cast("c_XMLNode*", 11)
mods\0luatest\lua\init.lua:18: 'struct c_XMLNode' has no member named 'm_GetRandomEnemy'
stack traceback:
        mods\0luatest\lua\init.lua:18: in function <mods\0luatest\lua\init.lua:14>
        [C]: in function 'xpcall'
        nl_luainit.lua:451: in function <nl_luainit.lua:450>
[←[33mNecroLuaAPI.dll←[0m] nl_payload.c:150: Mod API finalized.
[NecroLua.exe] nl_launcher.c: 58: Done with exit code 0x00000001

@pancelor pancelor added the bug Something isn't working label Sep 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant