RushDuel.SelectAndDoAction
Alias: RD.SelectAndDoAction. Requires the matching Rush Duel Lua bootstrap.
Signature
RushDuel.SelectAndDoAction(int hint, function filter, int tp, int s_range, int o_range, int min, int max, Card|Group|nil expect, function action) -> anyDescription
Finds matching cards in the specified locations, asks tp to select a non-cancelable Group of min to max cards, and immediately calls action(selected_group). Use during resolution, not during a chk==0 legality test. This helper does not select activation targets or store a target relation. The public wrapper passes only a Card to filter and only the selected Group to action; capture other values in closures or compose a filter with RD.Filter. It emits a selection hint for public-location searches. If there are too few candidates or the selected Group is empty, it returns numeric 0 without calling action. On a nonempty selection it forwards every return value from action unchanged. A callback with no return makes this helper return no values (nil in a single-value assignment); it does not automatically return the selected count or success.
Parameters
hintint: Selection prompt identifier, such as HINTMSG_TOGRAVE or aux.Stringid(id, n).filterfunction: Card predicate. Include the needed operation-legality checks.tpint: Selecting player; 0 or 1.s_rangeint: Locations on tp's side.o_rangeint: Locations on the opponent's side.minint: Minimum selected count.maxint: Maximum selected count.expectCard|Group|nil: Card(s) excluded from matching; pass nil for no exclusion. The upstream parameter is spelled expect.actionfunction: Called as action(selected_group) immediately after a nonempty selection.
Returns
any: Exactly the callback's return values when invoked; otherwise numeric 0. A callback may return no values.
Example
local moved = RD.SelectAndDoAction(HINTMSG_TOGRAVE,
Card.IsAbleToGrave, tp, LOCATION_MZONE, 0, 1, 1, nil,
function(g) return Duel.SendtoGrave(g, REASON_EFFECT) end)
if moved > 0 then
-- The returned movement count is positive.
endSource
Rush/Utilities/RDAction.lua:102
function RushDuel.SelectAndDoAction(hint, filter, tp, s_range, o_range, min, max, expect, action)
local hint_selection = RushDuel._private_is_include_public(s_range, o_range)
return RushDuel._private_action_select_match(hint, filter, tp, s_range, o_range, min, max, expect, hint_selection, false, action)
endGuided Examples
Learn how to use this function in context:
Used By
Generated from the local Rush/Scripts/ folder and rush_cards.cdb.
- Detected in 988 indexed script(s).
- Search this function in the Script Explorer with
RushDuel.SelectAndDoAction.
Script Examples
Elemental Circulation (120263030)
Source: Rush/Scripts/c120263030.lua
function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if RD.Draw()~=0 then
RD.SelectAndDoAction(HINTMSG_TOGRAVE,Card.IsAbleToGrave,tp,LOCATION_HAND,0,1,1,nil,function(g)
Duel.BreakEffect()
Duel.SendtoGrave(g,REASON_EFFECT)Moonforce Ziggy (120300014)
Source: Rush/Scripts/c120300014.lua
end
function cm.operation(e,tp,eg,ep,ev,re,r,rp)
RD.SelectAndDoAction(aux.Stringid(m,1),cm.filter,tp,0,LOCATION_MZONE,1,1,nil,function(g)
local tc=g:GetFirst()
local e1=Effect.CreateEffect(e:GetHandler())Freshberry Collaboration (120301071)
Source: Rush/Scripts/c120301071.lua
function cm.operation(e,tp,eg,ep,ev,re,r,rp)
local filter=RD.Filter(cm.filter,e,tp)
RD.SelectAndDoAction(HINTMSG_POSCHANGE,filter,tp,LOCATION_MZONE,0,1,1,nil,function(g)
if RD.ChangePosition(g,e,tp,REASON_EFFECT,POS_FACEUP_DEFENSE)~=0 and e:GetLabel()==1 then
RD.CanSelectAndDoAction(aux.Stringid(m,1),HINTMSG_DESTROY,cm.desfilter,tp,0,LOCATION_MZONE,1,1,nil,function(sg)