i created this scripts using the
card effect text and not your scripts as the guidelines.
I created 2 versions of the field spell:
version 1: the field spell when activated adds 1 to 3 karakuri
function c712559.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetOperation(c712559.activate)
c:RegisterEffect(e1)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetRange(LOCATION_SZONE)
e3:SetTarget(c712559.lvtg)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetValue(2000)
c:RegisterEffect(e3)
end
function c712559.lvtg(e,c)
return c:IsSetCard(0x11)
end
function c712559.filter(c)
return c:IsSetCard(0x11) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c712559.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_DECK) and c712559.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c712559.filter,tp,LOCATION_DECK,0,3,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c712559.filter,tp,LOCATION_DECK,0,3,3,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,3,0,0)
end
function c712559.activate(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local g=Duel.GetMatchingGroup(c712559.filter,tp,LOCATION_DECK,0,nil)
if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(712559,0)) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=g:Select(tp,3,3,nil)
Duel.SendtoHand(sg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sg)
end
end
version 2 can only be activated if you have at least 3 or more karakuri monsters in your deck, otherwise cannot be activated
function c712559.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c712559.target)
e1:SetOperation(c712559.activate)
c:RegisterEffect(e1)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetRange(LOCATION_SZONE)
e3:SetTarget(c712559.lvtg)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetValue(2000)
c:RegisterEffect(e3)
end
function c712559.lvtg(e,c)
return c:IsSetCard(0x11)
end
function c712559.filter(c)
return c:IsSetCard(0x11) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c712559.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_DECK) and c712559.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c712559.filter,tp,LOCATION_DECK,0,3,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c712559.filter,tp,LOCATION_DECK,0,3,3,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,3,0,0)
end
function c712559.activate(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local sg=g:Filter(Card.IsRelateToEffect,nil,e)
if sg:GetCount()>0 then
Duel.SendtoHand(sg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sg)
end
end
the reason why i created 2 versions is because some cards can only be activated if you have the necessary cards, others are optional, since your text can apply to both cases (in my opinion) i scripted both
in last i scripted the level changing monster following the card text effect
function c26082117.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(26082117,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c26082117.tg)
e1:SetOperation(c26082117.op)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
c:RegisterEffect(e3)
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e4:SetTargetRange(0,1)
c:RegisterEffect(e4)
end
function c26082117.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local t={}
local i=1
local p=1
local lv=e:GetHandler():GetLevel()
for i=1,8 do
if lv~=i then t[p]=i p=p+1 end
end
t[p]=nil
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(26082117,1))
e:SetLabel(Duel.AnnounceNumber(tp,table.unpack(t)))
end
function c26082117.op(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_LEVEL)
e1:SetValue(e:GetLabel())
c:RegisterEffect(e1)
end
end