-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,28 +67,11 @@ local def = { | |
| -- Allow all items with energy storage to be placed in the inventory | ||
| allow_metadata_inventory_put = function(pos, listname, _, stack, player) | ||
| if listname == "batteries" then | ||
| if not minetest.global_exists("technic") then | ||
| return 0 | ||
| end | ||
|
|
||
| local node_name = stack:get_name() | ||
|
|
||
| -- Allow all items with energy storage from technic mod | ||
| if technic.power_tools[node_name] ~= nil then | ||
| local meta = stack:get_metadata() | ||
| local md = minetest.deserialize(meta) | ||
| -- And specifically if they hold any charge | ||
| -- Disregard empty batteries, the player should know better | ||
| if md and md.charge > 0 then | ||
| if digtron.check_protected_and_record(pos, player) then | ||
| return 0 | ||
| end | ||
| return stack:get_count() | ||
| else | ||
| if minetest.global_exists("technic") and technic.get_charge(stack) > 0 then | ||
| if digtron.check_protected_and_record(pos, player) then | ||
| return 0 | ||
| end | ||
| else | ||
| return 0 | ||
| return stack:get_count() | ||
| end | ||
| end | ||
| return 0 | ||
|
|
@@ -116,12 +99,9 @@ local def = { | |
| return inv:add_item("batteries", stack) | ||
| end, | ||
| can_insert = function(pos, _, stack) | ||
| local meta = stack:get_metadata() | ||
| local md = minetest.deserialize(meta) | ||
| -- And specifically if they hold any charge | ||
| -- 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the previous comment about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment is back.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function should be logically equivalent to |
||
| local meta = minetest.get_meta(pos) | ||
| local inv = meta:get_inventory() | ||
| return inv:room_for_item("batteries", stack) | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.