Group.GetFirst
Signature
lua
Group.GetFirst(Group g) -> Card|nilDescription
Returns the first card in g and resets g's internal iterator to that card. Returns nil when g is empty.
How To Use It
Use GetFirst/GetNext to iterate through a Group when helper iterators are not available.
lua
local tc=g:GetFirst()
while tc do
-- work with tc
tc=g:GetNext()
endGetFirst resets the Group's internal pointer. Starting a second iteration on the same Group resets that pointer again.
Parameters
gGroup
Returns
Card|nil
Source
D:\Programs\GitHub\ygopro-core\libgroup.cpp:909
Guided Examples
Learn how to use this function in context:
- Common Script Errors And Debugging
- Conditions, Costs, Activation Procedures, and Resolution
- Filters, Card Objects, and Group Objects
- Selection And Group Handling
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 3591 indexed script(s).
- Search this function in the Script Explorer with
Group.GetFirst.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
lua
local g=Duel.SelectMatchingCard(tp,s.posfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.HintSelection(g)
local tc2=g:GetFirst()
Duel.ChangePosition(tc2,POS_FACEDOWN_DEFENSE)
endAstrograph Sorcerer, the Starfrost Magician (48171151)
Source: Scripts/c48171151.lua
lua
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g=Duel.SelectMatchingCard(tp,s.pfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,tp)
local tc=g:GetFirst()
if tc and Duel.MoveToField(tc,tp,tp,LOCATION_PZONE,POS_FACEUP,true) then
local e1=Effect.CreateEffect(c)Artmage Non-Finito (74631897)
Source: Scripts/c74631897.lua
lua
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_DECK,0,1,1,nil)
local tc=g:GetFirst()
if tc then
Duel.SSet(tp,tc)