Skip to content

Group.GetFirst ​

Signature ​

lua
Group.GetFirst(Group g) -> Card|nil

Description ​

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()
end

GetFirst resets the Group's internal pointer. Starting a second iteration on the same Group resets that pointer again.

Parameters ​

  • g Group

Returns ​

  • Card|nil

Source ​

  • D:\Programs\GitHub\ygopro-core\libgroup.cpp:909

Guided Examples ​

Learn how to use this function in context:

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.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua2
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua3
Artmage Non-Finito74631897Scripts/c74631897.lua2
Pendulum Evolution55795155Scripts/c55795155.lua2
Lady's Dragonmaid48658295Scripts/c48658295.lua1
Eternal Favorite87532344Scripts/c87532344.lua2
Surprise Fusion35167375Scripts/c35167375.lua3
Astrograph Sorcerer76794549Scripts/c76794549.lua4
Spellbook of the Grand Circle11911336Scripts/c11911336.lua1
Ultra Polymerization76647978Scripts/c76647978.lua2
Goyo Emperor59255742Scripts/c59255742.lua4
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua5
Melffy Playtime Surprise58036097Scripts/c58036097.lua1
Ashtraja Susanoo17020474Scripts/c17020474.lua1
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua4
Destiny HERO - Destro-Dogma25158975Scripts/c25158975.lua1
Yomagna the Fire Phantom17350692Scripts/c17350692.lua1
Fiendsmith's Sequence49867899Scripts/c49867899.lua1
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua1
El Shaddoll Apkallone50907446Scripts/c50907446.lua4
Mementotlan Fusion66518509Scripts/c66518509.lua1
Meteoroa Drytron24166324Scripts/c24166324.lua1
Favorite HERO Flame Wingman13243124Scripts/c13243124.lua1
Mixousia the Confounder80843006Scripts/c80843006.lua2
...and 3567 more

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)
		end

Astrograph 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)