Duel.GetLocationCount
Signature
lua
Duel.GetLocationCount(int player, int location, [int use_player], [int reason], [int zone]) -> int,intDescription
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
playerint- Player whose field is checked.locationint- Location to count, normally LOCATION_MZONE or LOCATION_SZONE.use_playerintoptional - Player treated as placing the card. Defaults to the current reason player.reasonintoptional - Placement reason such as LOCATION_REASON_TOFIELD or LOCATION_REASON_CONTROL. Defaults to LOCATION_REASON_TOFIELD.zoneintoptional - 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:
- Activation Legality
- Common Script Errors And Debugging
- Field Zones And Sequences
- Pendulum Procedure Guide
- Special Summon-Only Monster Guide
- Tribute Summon Materials
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.
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
endPendulum 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 endLevia-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)