Help fixing an Origins PW
Posted: 26 Oct 2015, 20:14
I've been dissatisfied with the way Origins PWs work, and I've been trying to work out a different way to code them. To that end, I've added the following lines to the PLW.LOL:
[
Can anyone pinpoint where I've gone wrong and help me get back onto the right track? Any help would be greatly appreciated.
- Code: Select all
PLWORI_NameSet = function(nameset, index)
local t = {}
t.EINHANDER = {
"OBLIVION_RING",
"SKYBIND",
"QUARANTINE_FIELD",
"GLIMMERPOINT_STAG",
"EXCLUSION_RITUAL",
"DETENTION_SPHERE",
"BANISHING_LIGHT",
"ADMONITION_ANGEL"
}
return t[nameset:upper()][index]
end
PLWORI_IsInNameSet = function(card, nameset)
-- returns true if card's name is in the given nameset
if card ~= nil and nameset ~= nil then
local index = 1
local name = PLWORI_NameSet(nameset, 1)
while name ~= nil do
if card:GetCardName() == name then
return true
end
index = index + 1
name = PLWORI_NameSet(nameset, index)
end
end
return false
end
PLWORI_FilterNameSet = function()
-- The Origins Planeswalker redirection filter
-- adds the given nameset to the filter (condition=true/1 means to include the names, otherwise the names will be excluded)
if filter ~= nil and nameset ~= nil then
local locfilter = filter
local operator = OP_NOT
if condition == 1 or condition == true then
locfilter = filter:AddSubFilter_Or()
operator = OP_IS
end
local index = 1
local name = PLWORI_NameSet(nameset, 1)
while name ~= nil do
locfilter:Add(FE_CARD_NAME, operator, name)
index = index + 1
name = PLWORI_NameSet(nameset, index)
end
end
end
- Code: Select all
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Whenever a land enters the battlefield under your control, if you control seven or more lands, exile Nissa, then return her to the battlefield transformed under her owner's control.]]></LOCALISED_TEXT>
<TRIGGER value="ZONECHANGE_END" simple_qualifier="objectyoucontrol" to_zone="ZONE_BATTLEFIELD" from_zone="ZONE_ANY">
return TriggerObject():GetCardType():Test( CARD_TYPE_LAND ) and EffectSource():GetZone() ~= ZONE_EXILE and EffectSource():GetZone() ~= ZONE_GRAVEYARD
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
filter:Add(FE_CONTROLLER, OP_IS, EffectController())
local total = filter:Count()
if total >= 7 and EffectSource() ~= nil then
local chest = EffectDC():Make_Chest(8)
chest:Set_CardPtr(0, EffectSource())
chest:Protect_CardPtr(0)
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(8)
if chest ~= nil and EffectSource() ~= nil then
EffectDC():Protect_CardPtr( COMPARTMENT_ID_EFFECT_SOURCE )
EffectSource():Exile()
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
if EffectSource():GetZone() == ZONE_EXILE then
MTG():PutTokensOntoBattlefield( "_NISSA_SAGE_ANIMIST_FA_4320005", 1, EffectSource():GetOwner(), EffectDC():Make_Chest(12) )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(12)
if chest ~= nil then
local token = chest:Get_NthCardPtr(0)
local source_chest = EffectDC():Get_Chest(8)
if source_chest ~= nil then
local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
if token ~= nil and Source ~= nil then
Source:NailOnto(token)
end
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(12)
if chest ~= nil then
local token = chest:Get_NthCardPtr(0)
local source_chest = EffectDC():Get_Chest(8)
if source_chest ~= nil then
local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
if token ~= nil and Source ~= nil then
local delayDC = EffectDC():Make_Chest(27)
delayDC:Set_CardPtr(0, token)
delayDC:Set_CardPtr(1, Source)
delayDC:Protect_CardPtr(0)
delayDC:Protect_CardPtr(1)
MTG():CreateDelayedTrigger(19, delayDC)
end
end
end
</RESOLUTION_TIME_ACTION>
<CLEANUP fire_once="1" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="19" replacement_effect="1">
<TRIGGER value="BECAME_TARGET_OF_ABILITY">
return TriggerObject() == EffectDC():Get_Chest(27):Get_CardPtr(0) and PLWORI_IsInNameSet(SecondaryObject(), "EINHANDER")
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(27)
local Source = EffectDC():Get_Chest(27):Get_CardPtr(1)
local secondary_object = SecondaryObject()
if chest ~= nil and Source ~= nil and secondary_object ~= nil then
local delayDC = EffectDC():Make_Chest(5)
delayDC:Set_CardPtr(0, Source)
delayDC:Set_CardPtr(1, secondary_object)
delayDC:Protect_CardPtr(0)
delayDC:Protect_CardPtr(1)
MTG():CreateDelayedTrigger(14, delayDC)
MTG():CreateDelayedTrigger(15, delayDC)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="14" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_ANY">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="15" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_EXILE">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
[
Can anyone pinpoint where I've gone wrong and help me get back onto the right track? Any help would be greatly appreciated.