Skip to content

Duel.GetLocationCount ​

Signature ​

lua
Duel.GetLocationCount(int player, int location, [int use_player], [int reason], [int zone]) -> int,int

Description ​

Returns how many zones of location are available on player's field and the corresponding usable zone mask. location is normally LOCATION_MZONE or LOCATION_SZONE. use_player, reason, and zone are used by effects that restrict where cards can be placed, such as Kaiser Colosseum-style restrictions. The count can be negative, so scripts that free a zone as a cost sometimes check ft > -1 instead of ft > 0.

Parameters ​

  • player int - Player whose field is checked.
  • location int - Location to count, normally LOCATION_MZONE or LOCATION_SZONE.
  • use_player int optional - Player treated as placing the card. Defaults to the current reason player.
  • reason int optional - Placement reason such as LOCATION_REASON_TOFIELD or LOCATION_REASON_CONTROL. Defaults to LOCATION_REASON_TOFIELD.
  • zone int optional - Zone mask to restrict the count. Defaults to 0xff.

Returns ​

  • int - Available zone count. The core comment notes this can be negative.
  • int - Usable zone mask.

Source ​

  • D:\Programs\GitHub\ygopro-core\libduel.cpp:4935

Guided Examples ​

Learn how to use this function in context:

Used By ​

Generated from the local Scripts/ folder and cards.cdb.

  • Detected in 5374 indexed script(s).
  • Search this function in the Script Explorer with Duel.GetLocationCount.
CardIDScriptDetected Calls
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua2
Pendulum Evolution55795155Scripts/c55795155.lua2
Levia-Dragoon - Daedalus78579058Scripts/c78579058.lua2
Lady's Dragonmaid48658295Scripts/c48658295.lua2
Azure Ocean Dragon Lord - Neo-Daedalus Rage41570943Scripts/c41570943.lua2
Eternal Favorite87532344Scripts/c87532344.lua1
Surprise Fusion35167375Scripts/c35167375.lua1
Astrograph Sorcerer76794549Scripts/c76794549.lua3
Ultra Polymerization76647978Scripts/c76647978.lua2
Goyo Emperor59255742Scripts/c59255742.lua4
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua2
Ashtraja Susanoo17020474Scripts/c17020474.lua3
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua2
Destiny HERO - Destro-Dogma25158975Scripts/c25158975.lua1
Yomagna the Fire Phantom17350692Scripts/c17350692.lua1
Fiendsmith's Sequence49867899Scripts/c49867899.lua2
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua3
Favorite HERO Flame Wingman13243124Scripts/c13243124.lua1
Invoked Sorath43989315Scripts/c43989315.lua1
Performage Cup Tricker6812770Scripts/c6812770.lua1
Ehther the Heavenly Monarch96570609Scripts/c96570609.lua2
Spirit Illusion71939275Scripts/c71939275.lua2
Pere-Zenet Em Heru46273941Scripts/c46273941.lua1
Am Duazenet45151304Scripts/c45151304.lua1
...and 5350 more

Script Examples ​

Astrograph Sorcerer, the Starfrost Magician (48171151) ​

Source: Scripts/c48171151.lua

lua
	if not c:IsCanBeSpecialSummoned(e,0,tp,false,false) or not c:IsControler(tp) then return false end
	if c:IsLocation(LOCATION_EXTRA) then return c:IsFaceup() and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0 end
	if c:IsLocation(LOCATION_GRAVE) then return aux.NecroValleyFilter()(c) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end
	return false
end

Pendulum Evolution (55795155) ​

Source: Scripts/c55795155.lua

lua
		if lpz==nil or rpz==nil then return false end
		local loc=0
		if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end
		if Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_PENDULUM)>0 then loc=loc+LOCATION_EXTRA end
		if loc==0 then return false end

Levia-Dragoon - Daedalus (78579058) ​

Source: Scripts/c78579058.lua

lua
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
		and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)