Creature comes into play -> untap up to X lands problem

Since this is my first post,
I'd like to say hi and thank you for this place to get new cards and the knowledge to create them yourself.
I tried it yesterday and got my first problem (but expected it ^^).
I tried to create the card "peregrine drake" (flying and untap of 5 lands).
The creation itself is no problem, nor is the flying.
But I got a problem with the untap-part...
I tried to use "buried alive" as a template and just alter it for the drake but it didn't work.
I also read the trigger for the "orcish settlers" but I don't get, what the Object():Register_Set( 3, 0 ) is for...
I'm no programming newbie but it's been some years till my last lines of code.
I attached the code for the drake, maybe you find my error (or can push me to the right direction).
I'd like to say hi and thank you for this place to get new cards and the knowledge to create them yourself.
I tried it yesterday and got my first problem (but expected it ^^).
I tried to create the card "peregrine drake" (flying and untap of 5 lands).
The creation itself is no problem, nor is the flying.
But I got a problem with the untap-part...
I tried to use "buried alive" as a template and just alter it for the drake but it didn't work.
I also read the trigger for the "orcish settlers" but I don't get, what the Object():Register_Set( 3, 0 ) is for...
I'm no programming newbie but it's been some years till my last lines of code.
I attached the code for the drake, maybe you find my error (or can push me to the right direction).
- Code: Select all
<TRIGGERED_ABILITY tag="PEREGRINE_DRAKE_RULE_2" layer="0" internal="1" pre_trigger="1" >
<TRIGGER value="COMES_INTO_PLAY">
return SelfTriggered()
</TRIGGER>
<TARGET_DETERMINATION>
Object():GetFilter():Clear()
Object():GetFilter():SetPlayer( Object():GetPlayer() )
Object():GetFilter():SetZone( ZONE_IN_PLAY )
Object():GetFilter():AddCardType( CARD_TYPE_LAND )
Object():GetPlayer():SetTargetCount( 5 )
local LNG_INDEX = 1
while LNG_INDEX < 6 do
Object():GetPlayer():ChooseTargetLand()
LNG_INDEX = LNG_INDEX + 1
end
Object():GetPlayer():ChooseTargets()
</TARGET_DETERMINATION>
<EFFECT>
if Object():GetNthTargetCard( 0 ) ~= nil then
Object():GetNthTargetCard( 0 ):Untap()
end
if Object():GetNthTargetCard( 1 ) ~= nil then
Object():GetNthTargetCard( 1 ):Untap()
end
if Object():GetNthTargetCard( 2 ) ~= nil then
Object():GetNthTargetCard( 2 ):Untap()
end
if Object():GetNthTargetCard( 3 ) ~= nil then
Object():GetNthTargetCard( 3 ):Untap()
end
if Object():GetNthTargetCard( 4 ) ~= nil then
Object():GetNthTargetCard( 4 ):Untap()
end
</EFFECT>
</TRIGGERED_ABILITY>