Skip to content
The Chat Archive
claude-instant-1· Anthropic Arena Human Preference 55K

this code i made for a edopro card script is not working as intended, it was not…

  1. User

    this code i made for a edopro card script is not working as intended, it was not supposed to do this "All your monsters currently on the field are immune to opponent card effects until the end of this turn." , my code: --Black ops 3 - In Plain Sight --card effect description: All your monsters currently on the field are immune to opponent card effects until the end of this turn. local s,id = GetID() function s.initial_effect(c) local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) end -- Make all the player's monsters immune to all opponent card effects until the end of this turn. function s.target(e, tp, eg, ep, ev, re, r, rp, chk) if chk == 0 then return Duel.IsExistingMatchingCard(Card.IsMonster, tp, LOCATION_ONFIELD, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsMonster, tp, LOCATION_ONFIELD, 0, 1, nil) end end function s.activate(e, tp, eg, ep, ev, re, r, rp) local c=e:GetHandler() local g = Duel.GetMatchingGroup(Card.IsMonster,tp,LOCATION_ONFIELD,0,nil) -- Loop through all cards in the group g and apply the immune effect using a for loop for tc in aux.Next(g) do local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetRange(LOCATION_MZONE) e1:SetValue(s.efilter) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function s.efilter(e,te) return te:GetOwner()~=e:GetOwner() end

  2. Assistant

    Okay I see a few issues with this code:

    1. The card name and description do not match the effect. The description says "All your monsters currently on the field are immune to opponent card effects until the end of this turn." but the code is making each monster individually immune, not all at once.

    2. The targeting function is checking for any 2 monsters, but the effect applies to all monsters. It should check for any number of monsters.

    3. The for loop has some issues:

    • It's using aux.Next which is not a standard Lua function. It should just be a regular for i=1,#g loop.

    • It's applying the immunity effect to the tc variable, but that variable is just a local variable in the for loop. It should apply the effect to g[i].

    So a corrected version would be something like:

    function s.target(e, tp, eg, ep, ev, re, r, rp, chk) if chk == 0 then return Duel.IsExistingMatchingCard(Card.IsMonster, tp, LOCATION_ONFIELD, 0, 1, nil)
    end end

    function s.activate(e, tp, eg, ep, ev, re, r, rp) local c=e:GetHandler() local g = Duel.GetMatchingGroup(Card.IsMonster,tp,LOCATION_ONFIELD,0,nil) for i=1,#g do local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT)
    e1:SetRange(LOCATION_MZONE) e1:SetValue(s.efilter)
    e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) g[i]:RegisterEffect(e1) end end

    Hope this helps! Let me know if you have any other questions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.

Identical first prompt