Skip to content

Fix "Batteryman Fuel Cell" nil check - #1281

Merged
NaimSantos merged 2 commits into
ProjectIgnis:masterfrom
fourlastor:patch-1
Oct 22, 2026
Merged

NaimSantos merged 2 commits into
ProjectIgnis:masterfrom
fourlastor:patch-1

Conversation

@fourlastor

Copy link
Copy Markdown
Contributor

This PR addresses an error that happens with Batteryman Fuel Cell: attempt to index a nil value (local 'tc')

The way to reproduce is:

  1. Have Batteryman Fuel Cell on P1's field
  2. Have another "Batteryman" monster on P1's field, equipped with a spell from P2 (in my case, I noticed it with "Mark of the Rose", but it should be the same for any equip spell)
  3. P2's equip spell is the only card on P2's field
  4. Use Batteryman Fuel Cell ability: "Once per turn, you can Tribute 1 "Batteryman" monster, except this card, to select 1 card your opponent controls and return it to its owner's hand."
  5. The "Batteryman" monster is tributed as the cost, destroying the equipped spell
  6. The effect then resolves with no target (tc is nil), and you get the error I mentioned above

@fourlastor
fourlastor requested a review from pyrQ as a code owner October 21, 2026 10:50
@NaimSantos

Copy link
Copy Markdown
Contributor

This is not the correct fix for this type of problem.

The general if tc check for targets should be reversed for mandatory trigger effects that target, which is a scenario where it is actually possible to a target not be present during the resolution. The if tc part will then prevent further script errors in that effect's resolution.

The correct approach here would be to check if there is a target that is not among the equip group of the card that is about to be used as the cost (because tributing that card will also cause the equip card(s) to leave the field).

Unfortunately, that only works for interactions with equip cards, but it fails in other scenarios, such as cards that have effects like "Destroy this card when that target/it leaves the field" (where "that target/it" = the card that is going to be used as cost.)

@fourlastor

Copy link
Copy Markdown
Contributor Author

Thank you for the review, that makes sense. I can address this by changing the activation check instead, do you want me to keep the if so that the script doesn't crash in the cases that aren't covered by the equip check?

@edo9300
edo9300 force-pushed the master branch 17 times, most recently from 118098b to dc441e0 Compare October 21, 2026 21:01
@fourlastor

Copy link
Copy Markdown
Contributor Author

@NaimSantos I changed the approach, following https://github.com/ProjectIgnis/CardScripts/blob/dc441e0473596531c86820619bacc39f10b2a6f8/official/c68508433.lua (Spirit Tech Force - Pendulum Ruler) which has a similar idea (tribute, then destroy)

return c:IsSetCard(SET_BATTERYMAN) and Duel.IsExistingTarget(Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,1,c:GetEquipGroup()+c)

A batteryman, and a card that can be targeted by the effect, on the field, excluding the equipped cards of that batteryman (as they would be destroyed when tributing)

@edo9300
edo9300 force-pushed the master branch 2 times, most recently from d417ff9 to e30e451 Compare October 22, 2026 07:38
@NaimSantos
NaimSantos merged commit 188c4b9 into ProjectIgnis:master Oct 22, 2026
1 check passed
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.

2 participants