-
Notifications
You must be signed in to change notification settings - Fork 35
fix(battery): Fix battery holder accepting technic charges #115
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
Conversation
51e7359 to
f7426af
Compare
|
I was just about to make a pr to do just that! Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to also update the digtron.tap_batteries function in https://github.com/minetest-mods/digtron/blob/master/util.lua#L265 so that it also uses technic's new way of storing the item's charge value.
f7426af to
a38b14d
Compare
|
Thanks to your comments I realized I did a very partial job :) Now inventory put, tube sending and battery consumption are fixed. I changed battery consumption so only power needed for next step is drained (it seemed better to me but may be it's not Digtron policy). |
a38b14d to
d99f368
Compare
| -- Disregard empty batteries, the player should know better | ||
| if md and md.charge > 0 then | ||
| meta = minetest.get_meta(pos) | ||
| if minetest.global_exists("technic") and technic.get_charge(stack) > 0 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the previous comment about -- Disregard empty batteries, the player should know better to justify the charge > 0 check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is back.
Anyway I was wondering if it would be better to accept empty batteries (seems more usual).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be logically equivalent to allow_metadata_inventory_put. The player (automated or manual action) should be made aware that the battery is not usable as-is. Some feedback is needed for them, and rejecting the movement transaction is about the most simple approach to do that.
Anyway. I think this should be kept.
d99f368 to
416686c
Compare
I always assumed that the whole charge of an itemstack was drained all at once because if we do that we don't have to keep running the code that takes the energy from itemstacks every time the digtron moves and can instead do it all at once. I would imagine digteon's old way would be good for big servers that may have many digtron's running all at once. I might be wrong, though. @SmallJoker might know. They seem to be way more active in the Luanti community and with this mod than I am. |
This is a fair argument. Whereas the PR makes it more realistic (decrement as needed), it also means that the itemstacks are updated every time in As a compromise, we could instead drain - say - 5x the target energy and break afterwards. I wouldn't recommend more optimizations in this function, as |
|
Just to be clear, I'm not arguing for one approach over the other. I was just making an observation. In situations like this I would just make a setting and call it a day. I just want the fix merged and everyone happy. :) |
|
The possible performance issue is very interesting. |
416686c to
d7bd622
Compare
d7bd622 to
148293d
Compare
|
Okay, sure. Without further ado - LGTM. |
A quick & dirty fix for making battery holder working with current version of Luanti & Tehnic.
Using both master versions, battery holder always reject charged objects (md is nil).
I just updated code to use new get_meta api and "technic:charge" metadata name.