The following code will be somewhere inside an ability:
- Code: Select all
<RESOLUTION_TIME_ACTION>
local card = EffectSource() -- if it's not the card itself that you want to move, change this
if card ~= nil then
EffectDC():Protect_CardPtr(COMPARTMENT_ID_EFFECT_SOURCE) -- protect the pointer before moving the card, or you won't find it anymore! EffectSource is a special pointer whose register number is accessible with the COMPARTMENT_ID_EFFECT_SOURCE constant so you need to protect it this way: if it's not the card itself that you want to move, change this as well
card:Exile() -- you can move the card now
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local card = EffectSource() -- if it's not the card itself that you want to move, change this too
if card ~= nil then
local delayDC = EffectDC():Make_Chest(1) -- make a chest in a free register
delayDC:Set_CardPtr(0, card) -- save the card (no need to protect the pointer here, the zone change has been already done)
MTG():CreateDelayedTrigger(1, delayDC) -- start the delayed trigger with resource_id="1" and pass delayDC to it, which will become the trigger's EffectDC
end
</RESOLUTION_TIME_ACTION>
Then you have the delayed trigger as an additional ability on the card:
- Code: Select all
<TRIGGERED_ABILITY resource_id="1">
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_END_OF_TURN
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local card = EffectDC():Get_CardPtr(0) -- because that's where you saved the card on delayDC
if card ~= nil then
card:PutInGraveyard() -- move the card again
end
</RESOLUTION_TIME_ACTION>
<CLEANUP fire_once="1" />
</TRIGGERED_ABILITY>
Note that I made a delayed trigger "at the beginning of the next end step", not necessarily
your end step, because Magic cards usually work this way. If you really want
your end step only, then add simple_qualifier="controller".