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

lottthrowing crash #190

Open
MoNTE48 opened this issue Jul 16, 2023 · 4 comments
Open

lottthrowing crash #190

MoNTE48 opened this issue Jul 16, 2023 · 4 comments

Comments

@MoNTE48
Copy link

MoNTE48 commented Jul 16, 2023

2023-07-16 05:58:37: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'lottthrowing' in callback luaentity_Step(): ...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:120: attempt to index field 'player' (a nil value)
2023-07-16 05:58:37: ERROR[Main]: stack traceback:
2023-07-16 05:58:37: ERROR[Main]: 	...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:120: in function <...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:84>
@MoNTE48
Copy link
Author

MoNTE48 commented Jul 16, 2023

- if self.player ~= "" then
+ if self.player and self.player:is_player() then

@lumidify
Copy link
Contributor

Hi,

Thanks for the bug report. I was about to commit your fix, but I think there's more to the bug than meets the eye at first. If you look in the function lottthrowing_shoot_arrow in init.lua, the field player of the placed entity is set to the actual ObjectRef of the player, which is probably not the sensible thing to do here (and then it doesn't make any sense to compare player to ""). I'm assuming that this should actually be set to the name of the player instead. Then the on_step callback in arrow.lua can use minetest.get_player_by_name to get the actual player.

@neinwhal thoughts?

@MoNTE48
Copy link
Author

MoNTE48 commented Jul 16, 2023

@lumidify, that's a good point.
I suggested a simple fix given that LOTT is in maintenance mode. But I'm always in favor of a more proper and clean way of doing things.

@neinwhal
Copy link
Member

good eye, yeah, the logic is broken. seems like a lazy attempt by me 7 years back to attempt to get mob detection for arrows; 44c16f7
I should probably look through the rest of outdated code to spot for any other broken logic as well...

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

3 participants