Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
New MTG Cards and Decks (2010, 2012, 2013, 2014, 2015, Magic Duels)
2014




Help with error = attempt to index a nil value
Moderator: CCGHQ Admins
5 posts
• Page 1 of 1
Help with error = attempt to index a nil value
by Luchian » 02 May 2014, 18:51
I'm having a time of it trying to work out why I keep getting the error :
[lua] [string "COORDINATED_BARRAGE_153151_TITLE (RESOLUTION_TIME_ACTION)~0x000005ea"]:2: attempt to index a nil value
on the following card I made for Coordinated Barrage.
I used Sumomole's Adaptive Automaton and code for the base and the card seems to work just fine. I keep getting this error when I quit though and I keep trying to fix it but I think I have been looking at code too long the past few weeks and I have no idea what to do to get rid of the error.
Here is the code :

[lua] [string "COORDINATED_BARRAGE_153151_TITLE (RESOLUTION_TIME_ACTION)~0x000005ea"]:2: attempt to index a nil value
on the following card I made for Coordinated Barrage.
I used Sumomole's Adaptive Automaton and code for the base and the card seems to work just fine. I keep getting this error when I quit though and I keep trying to fix it but I think I have been looking at code too long the past few weeks and I have no idea what to do to get rid of the error.
Here is the code :
- Code: Select all
<SPELL_ABILITY>
<SFX text="TARGET_PIERCE_PLAY" />
<TARGET tag="CARD_QUERY_CHOOSE_CREATURE_DEAL_DAMAGE" definition="0" compartment="0" count="1" />
<TARGET_DEFINITION id="0">
local filter = ClearFilter()
filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
local subFilter = filter:AddSubFilter_Or()
subFilter:Add(FE_IS_ATTACKING, true)
subFilter:Add(FE_IS_BLOCKING, true)
</TARGET_DEFINITION>
<RESOLUTION_TIME_ACTION>
local zone = ZONE_ANYWHERE
local player = EffectController()
S_CountCreatureTypes(zone, player)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
local player = EffectController()
return S_ChooseCreatureType(player)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
LinkedDC():Set_Int(0, S_ChosenCreatureType())
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(0)
if ( target_creature ~= nil ) then
local filter = ClearFilter()
filter:Add( FE_SUBTYPE, OP_IS, S_ChosenCreatureType() )
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
local damage = filter:Count()
EffectSourceLKI():DealDamageTo( damage, target_creature )
end
</RESOLUTION_TIME_ACTION>
<AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ENEMY_ONLY" />
</SPELL_ABILITY>

Re: Help with error = attempt to index a nil value
by MC Brodie » 02 May 2014, 19:03
From the error message I'm guessing it's the line that says:
viewtopic.php?f=63&t=11418&start=75#p145343
- Code: Select all
local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(0)
- Code: Select all
local target_creature = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
viewtopic.php?f=63&t=11418&start=75#p145343
-----------------------------------------------------------------------
Song of the Day: 46 and 2 (cover)
Song of the Day: 46 and 2 (cover)
Re: Help with error = attempt to index a nil value
by Luchian » 02 May 2014, 20:43
Thanks for your help. Sadly it didn't work and I'm still getting that error. 

Re: Help with error = attempt to index a nil value
by sumomole » 02 May 2014, 21:48
del LinkedDC, it's redundant.
EDIT: for Coordinated Barrage, you should use ZONE_BATTLEFIELD rather than ZONE_ANYWHERE, because it just count your permanents.
EDIT: for Coordinated Barrage, you should use ZONE_BATTLEFIELD rather than ZONE_ANYWHERE, because it just count your permanents.
-
sumomole - Programmer
- Posts: 611
- Joined: 07 Jun 2011, 08:34
- Has thanked: 51 times
- Been thanked: 234 times
Re: Help with error = attempt to index a nil value
by Luchian » 02 May 2014, 22:31
Just tested it and it worked. Thank you!
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests