Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pyrollo
Copy link
Contributor

@pyrollo pyrollo commented Aug 16, 2025

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.

@pyrollo pyrollo force-pushed the pyrollo/fix-battery branch from 51e7359 to f7426af Compare August 16, 2025 16:16
@DustyBagel
Copy link

I was just about to make a pr to do just that! Thanks.

Copy link

@DustyBagel DustyBagel left a 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.

@pyrollo pyrollo force-pushed the pyrollo/fix-battery branch from f7426af to a38b14d Compare August 20, 2025 08:59
@pyrollo
Copy link
Contributor Author

pyrollo commented Aug 20, 2025

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).

-- 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
Copy link
Member

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.

return 0
end
else
return 0
return stack:get_count()
Copy link
Member

@SmallJoker SmallJoker Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really intend to allow any player to use this slot for arbitrary storage if technic is not installed?
EDIT: The GitHub web diff view is misleading. Please ignore this comment.

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

Successfully merging this pull request may close these issues.

3 participants