-
Notifications
You must be signed in to change notification settings - Fork 1
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
Owner-less tpads cause errors #5
Comments
Thank you @BramvdnHeuvel - could you check the fix in the latest commit and let me know if that seems good for now? Not sure I'd be able to investigate about supporting procedurally spawned tpads as it happens with the other issue you linked, I would appreciate pointers about what's needed - if it's something trivial to implement I'd be happy to. |
The code looks good - I will test whether the code works in practice! 🙌 Concerning naturally spawning tpads, I have found that the bug is unrelated to the tpad mod - so there's no need to spend time on that. Since I'm personally not interested in procedurally spawning tpads (I want them to be rare and difficult to craft, not easily available), I would like to run some code (which I'm totally fine with running in a separate mod) that automatically destroys tpads with no owner. That way, even if a mod wrongly generates a tpad, I can stop players from finding them. |
Nice - I saw the comments on that other issue, definitely looks like a caching issue of some sort independent from this mod - by the way, happy to see tpad being used around, in particular if it's being treated as a precious rarity 😄 |
I have tested and the code works beautifully. Thanks a lot! ❤️ I'll close the issue. If it pleases you, I can tell you that it is used as the ultimate item in our personal server. There's a custom block for every player on the server, and players have to find/craft all them to combine them into one tpad. :) I'm going to write a little script that automatically removes all ownerless tpads (probably with an LBM). Is there a simple way to check who's the owner of a tpad that can be used outside of this mod? |
You're welcome - very glad to read about that! As for checking the ownerless entries honestly not sure - as far as my mod is concerned, the only data it sees is really that file you mentioned, it doesn't even do anything with the dug blocks other than checking whether they can be dug or not: https://github.com/entuland/tpad/blob/master/init.lua#L493-L503 In theory you could edit that code so that it returns false when ownername is nil or empty, instead of just allowing the block to be dug - then your players wouldn't be able to dig it, but would still be able to interact with it possibly? reading this other section it would seem so: https://github.com/entuland/tpad/blob/master/init.lua#L461-L466 Going through spawned nodes as chunks get emerged or loaded to ensure such malformed instances are automatically removed would be a completely different thing (and honestly I wouldn't know where to start, other than possibly investigating if you can override the actual digging action to run your own checks: then you could probably make it so that the block does get removed from the world but the player doesn't get the item in their inventory) |
Oh well, I kind of failed to get your point - if you know how to go about inspecting nodes and removing them, all you need really is checking if the node is a tpad and query the meta to see if it has an owner, just like the first code I mentioned does when checking whether the node can be dug. |
Tpads without an owner cause the global network to break. When an owner-less tpad is broken, they add a field to the mod storage that cannot be parsed properly.
How to replicate
What is going wrong?
The issue is related to the tpad mod being unable to handle tpads that have no owner. Usually, the tpad storage in
mod_storage.sqlite
looks as follows:However, when destroying a tpad with no owner, the mod storage is updated to the following:
A new field is added where the key is simply
pads:
with no owner attached. When looking up the global network, this makes the tpad mod crash.The text was updated successfully, but these errors were encountered: