Skip to content

RushDuel.SelectAndDoAction ​

Alias: RD.SelectAndDoAction. Requires the matching Rush Duel Lua bootstrap.

Signature ​

lua
RushDuel.SelectAndDoAction(int hint, function filter, int tp, int s_range, int o_range, int min, int max, Card|Group|nil expect, function action) -> any

Description ​

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 ​

  • hint int: Selection prompt identifier, such as HINTMSG_TOGRAVE or aux.Stringid(id, n).
  • filter function: Card predicate. Include the needed operation-legality checks.
  • tp int: Selecting player; 0 or 1.
  • s_range int: Locations on tp's side.
  • o_range int: Locations on the opponent's side.
  • min int: Minimum selected count.
  • max int: Maximum selected count.
  • expect Card|Group|nil: Card(s) excluded from matching; pass nil for no exclusion. The upstream parameter is spelled expect.
  • action function: 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 ​

lua
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.
end

Source ​

Rush/Utilities/RDAction.lua:102

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

Guided 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.
CardIDScriptDetected Calls
Elemental Circulation120263030Rush/Scripts/c120263030.lua1
Moonforce Ziggy120300014Rush/Scripts/c120300014.lua1
Freshberry Collaboration120301071Rush/Scripts/c120301071.lua1
Voidalfr Star Mayfly120300034Rush/Scripts/c120300034.lua1
Player #C39: Home Run Smasher V120305028Rush/Scripts/c120305028.lua1
Invitation to a Delirious Dream120261066Rush/Scripts/c120261066.lua1
Light of Bewitchment120301074Rush/Scripts/c120301074.lua1
Dark-Guiding Kuriboh120280009Rush/Scripts/c120280009.lua1
Delirium Lampyris120231061Rush/Scripts/c120231061.lua1
Super Galaxy King Lord of Galactica [R]120254039Rush/Scripts/c120254039.lua1
Fuden Issen120309034Rush/Scripts/c120309034.lua1
Wako Gozen Riletta120309021Rush/Scripts/c120309021.lua1
Sparkhearts Makma120298023Rush/Scripts/c120298023.lua1
Imaginary Arc Turbulence120196013Rush/Scripts/c120196013.lua1
Major Breaking News!120304060Rush/Scripts/c120304060.lua1
Abyssal Dragon Lord Abyss Poseidra [L]120239013Rush/Scripts/c120239013.lua1
Wish of the Skysavior120253064Rush/Scripts/c120253064.lua1
Fairy of the Stars120305016Rush/Scripts/c120305016.lua1
Necromaid Trickment120294063Rush/Scripts/c120294063.lua1
Spice Cross Secret Recipe120261060Rush/Scripts/c120261060.lua1
Magical Retribution120254028Rush/Scripts/c120254028.lua1
Nobody Phantom Thief120244060Rush/Scripts/c120244060.lua1
Nobody Phantom Thief120273005Rush/Scripts/c120273005.lua1
Mega Jointech Fortrex [R]120249005Rush/Scripts/c120249005.lua2
...and 964 more

Script Examples ​

Elemental Circulation (120263030) ​

Source: Rush/Scripts/c120263030.lua

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

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

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)