sieders1
2017-09-07T17:21:01Z
I'm trying to understand the Duel.GetChainInfo() function so I can really write a thorough Superdora function, but I'm struggling to figure it out.

So far, I think if i run Duel.GetChainInfo(1, CHAININFO_TRIGGERING_EFFECT) this will return (something) that belongs to the first(?) / last(?) chain link, but that's almost a complete guess. If anyone could help me out that would be much appreciated, particularly, what does this Duel.GetChainInfo() return? and what do i need to know about what it returned?

Thanks
"All things in moderation" has to include moderation as well, right?
andre060
2017-09-07T19:05:16Z
well, Duel.GetChainInfo() is used to get chaininfo, for example, soul max:

function c54447022.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    ...
    local g=Duel.SelectTarget(tp,c54447022.filter,tp,LOCATION_GRAVE,0,1,ft,nil,e,tp)
    ...
end
function c54447022.spop(e,tp,eg,ep,ev,re,r,rp)
    ...
    local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
    ...
end
in that case, getchaininfo will get own operation (as it specifies with 0), also it get the target card (CHAININFO_TARGET_CARDS).
so what that return depend's on chainc and what you wanting to get, so.

Duel.GetChainInfo(1, CHAININFO_TRIGGERING_EFFECT)
will get the first trigering effect of chain link 1 (probaly), i bet it return a effect.
poi
sieders1
2017-09-08T01:03:12Z
when you say it would return an effect, what exactly does that mean?

is the effect an object with fields and whatnot or does it return the card object?
or does it return the constants like EFFECT_SKIP_BP?

Put another way, what can i safely do with the output of the function without causing a lot of errors?
"All things in moderation" has to include moderation as well, right?
Snarky
2017-09-08T21:07:10Z
As andre states, Duel.GetChainInfo returns information provided by the current chain, depending on the parameters you give it. First parameter is always the chain link, so for your example, it would always get the info for chain link 1, the first card/effect to be activated in the chain and the last to be resolved (just to clarify. Surely you know, how the chains work 🙂 )

Your second parameter is CHAININFO_TRIGGERING_EFFECT, which is exactly what it says, the effect, that triggers the chain link. This is the effect of the card, that is activated as the chain link 1. An effect is an object used in scripting cards for YGOPro. Do note, that this is a whole different monster compared to AI scripting. You might have had a look at the scripts of the YGOPro cards before, here you will find effects everywhere. Every card usually has multiples of these, and most functions get effects passed to them as their first parameter (usually just called "e").

If you are not familiar with card scripting, you might get overwhelmed here, as card scripting is a different entity compared to ai scripting. You'll have to handle different types, use different functions in a different way etc ect. Have a look at Fluo's GitHub  for possible functions to interact with the effect type.

Do note, that effect is a "userdata" type, not a table like the ones you're used to from AI scripting. You cannot access the fields of an effect, you'll have to use the appropriate get/set funtions to interact with them:


local e = Duel.GetChainInfo(1,CHAININFO_TRIGGERING_EFFECT)
local c = e:GetHandler() 

-- "Handler" is the card handling the effect. Do note, that this is a card script object. Not the same as a card object you would get from an AI script function. Confusing, I know.

local id = c:GetCode()  -- the ID of the card
local target = e:GetTarget()

 -- and this is how you could get some useful information of an effect like that maybe

What exactly do you want to achieve?
sieders1
2017-09-10T03:07:56Z
Thanks. That's actually exactly what I was looking for.

Ya that seems like a lot of work but I think it might be the best way to code a Superdora unless I figure something else out.

Thanks again
"All things in moderation" has to include moderation as well, right?