Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The party[] array in Lua scripts is nil #159

Open
OnlineCop opened this issue Dec 21, 2022 · 4 comments
Open

The party[] array in Lua scripts is nil #159

OnlineCop opened this issue Dec 21, 2022 · 4 comments

Comments

@OnlineCop
Copy link
Owner

While troubleshooting the coliseum crash when entering Rufus' cabin, I noticed that interacting with the fire calls touch_fire(party[0]), but the party[] array appears to be nil.

It appears to also be nil in the other scrips where party[#] is used, such as book_talk(party[0]).

Do we have any idea where party gets initialized and/or updated? Is it within the Lua scripts, or back in the C++ code like in intrface.cpp somewhere?

@z9484
Copy link
Collaborator

z9484 commented Dec 21, 2022

Ugh I finally found it https://github.com/OnlineCop/kq-fork/blob/road_to_1.0/src/intrface.cpp#L923
Works on my machine(on pass.tmx). I have got that nil error before though. I think it might have been when the lua interpreter crashed for a map, so it was in a weird state.

@OnlineCop
Copy link
Owner Author

I'm not sure; I started a new game and started to read bookshelves and fires where touch_fire() or book_talk() were used with party[...] and am seeing those errors (not just in the pass where the parallax may be causing some kind of error).

When the interpreter crashes, doesn't it usually dump an error to screen (still recoverable, and player can keep going)?

@z9484
Copy link
Collaborator

z9484 commented Dec 21, 2022

Yes it should print an error to the console and then keep going. I started a new game and book_talk worked. Are using mac or linux?

@OnlineCop
Copy link
Owner Author

Actually, Win10. I wonder if Lua broke silently and I just don't see any error messages about it?

Watching a tutorial now (Lua C API tutorial) to see whether it was something with my Lua stack that I implemented wrong.

I've got an uneasy feeling that it has something to do with the fact that KPlayer is a C++ class (with std::string types) and KQEntity is a C-style POD (with plain length-known-at-compile-time char[] arrays)... I might need to make a KQPlayer POD (plain-old-data) struct to use instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants