>>479
例えば、あらかじめcXXXXXXXX[0]=0 cXXXXXXXX[1]=0ってしておいて、
フィルターで
cXXXXXXXX.filter(c,tp)
local code=c:GetCode()
for i=1,cXXXXXXXXX[tp] do
if code==cXXXXXXXXX[2*i+tp] then return false end
end
return true
end
選択後は
local n=cXXXXXXXXX[tp]+1
cXXXXXXXX[2*n+tp]=g:GetFirst():GetCode()
cXXXXXXXXX[tp]=n
とかね
たとえば、魔法カードの効果で「捕食植物ダーリング・コブラ」の効果を使用するために
フィルターを↓
function c2156.spfilter(c,e,tp)
return c:IsSetCard(0x10f3) and c:IsCanBeSpecialSummoned(e,4339,tp,false,false)
end
オペレーション箇所を↓
function c2156.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c2156.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,4339,tp,tp,false,false,POS_FACEUP)
end
end
function cカードID.chtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local ftg=re:GetTarget()
if chkc then return ftg(e,tp,eg,1-tp,ev,re,r,1-tp,chk,chkc) end
if chk==0 then return not ftg or ftg(e,tp,eg,1-tp,ev,re,r,1-tp,chk) end
e:SetProperty(re:GetProperty())
e:SetCategory(re:GetCategory())
if ftg then
ftg(e,tp,eg,1-tp,ev,re,r,1-tp,chk)
end
end
function cカードID.chop(e,tp,eg,ep,ev,re,r,rp)
local op=re:GetOperation()
if op then op(e,tp,eg,1-tp,ev,re,r,1-tp) end
if e:GetHandler():IsLocation(LOCATION_GRAVE) then
Duel.BreakEffect()
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_EFFECT)
end
end
因みにバルブの時は「local ftg=re:GetTarget()」、
シルバの時は「if chk==0 then return not ftg or ftg(e,tp,eg,1-tp,ev,re,r,1-tp,chk) end」に問題があると出ました。
スクリプトはこんな感じです↓。
function c1150.atkfilter(c,g)
return c:GetAttack()>=0 and c:IsPosition(POS_FACEUP_DEFENSE)
end
function c1150.atkval(e,c)
local g=Duel.GetMatchingGroup(c1150.atkfilter,c:GetControler(),LOCATION_MZONE,0,c)
return g:GetSum(Card.GetAttack)
end
function c1150.atkfilter(c,g)
return c:GetAttack()>=0 and c:IsPosition(POS_FACEUP_DEFENSE) and g:IsContains(c)
end
function c1150.atkval(e,c)
local lg=c:GetLinkedGroup()
local g=Duel.GetMatchingGroup(c1150.atkfilter,c:GetControler(),LOCATION_MZONE,LOCATION_MZONE,nil,lg)
return g:GetSum(Card.GetAttack)
end
function c001.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,532)
local tc=Duel.GetFirstTarget()
if tc:GetOverlayCount()==0 then return end
tc:RemoveOverlayCard(tp,1,99,REASON_EFFECT)
local ct=Duel.GetOperatedGroup():GetCount()
e:SetLabel(ct)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<0 then return end
local tc=Duel.GetFirstTarget()
if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local c=e:GetHandler()
local ct=e:GetLabel()
local g=Duel.SelectMatchingCard(tp,c001.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,tc:GetRank()+ct)
local sc=g:GetFirst()
if sc then
local mg=tc:GetOverlayGroup()
if mg:GetCount()~=0 then
Duel.Overlay(sc,mg)
end
sc:SetMaterial(Group.FromCards(tc))
Duel.Overlay(sc,Group.FromCards(tc))
Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)
sc:CompleteProcedure()
end
end
失礼しました。エラーログは出ませんでした。効果の起動を確認するためのスクリプトです。
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetRange(LOCATION_SZONE)
e1:SetCode(EVENT_REMOVE_COUNTER+0x100e)
e1:SetOperation(c37564.winop)
c:RegisterEffect(e1)
function c37564.winop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_CARD,0,37565)
end
「A」細胞培養装置を参考にAカウンター取り除いて試しているのですが何が悪いのでしょうか?
現在スクリプトを作っているものです。今は「レッド・デーモンズ・ドラゴン・タイラント」のスクリプトを作っているのですが[string"./script/c10004.lua]:4:attempt to call field"Tuner"(a nil value)と出てしまいます。ygopro ver.1.34.2では普通に召喚出来るのですがygopro ver1.033.C では召喚出来ませんでした。4行目に欠陥があるのは分かるのですがどうすれば召喚できるのか分かりません。お時間があるときで大丈夫なので知恵を貸していただけると有り難いです。
--レッド・デーモンズ・ドラゴン・タイラント
function c10004.initial_effect(c)
--synchro summon
aux.AddSynchroMixProcedure(c,aux.Tuner(nil),aux.Tuner(nil),nil,aux.NonTuner(nil),1,99)
c:EnableReviveLimit()
--destroy
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetTarget(c10004.destg)
e2:SetOperation(c10004.desop)
c:RegisterEffect(e2)
--negate
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_CHAINING)
e3:SetCondition(c10004.discon)
e3:SetTarget(c10004.distg)
e3:SetOperation(c10004.disop)
c:RegisterEffect(e3)
--double tuner
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e4:SetCode(21142671)
c:RegisterEffect(e4)
end
function c10004.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler()) end
local g=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c10004.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,e:GetHandler())
if g:GetCount()>0 then
Duel.Destroy(g,REASON_EFFECT)
end
end
function c10004.ftarget(e,c)
return e:GetLabel()~=c:GetFieldID()
end
function c10004.discon(e,tp,eg,ep,ev,re,r,rp)
local ph=Duel.GetCurrentPhase()
return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and re:IsHasType(EFFECT_TYPE_ACTIVATE)
and Duel.IsChainNegatable(ev) and (ph>=PHASE_BATTLE_START and ph<=PHASE_BATTLE)
end
function c10004.distg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
end
end
function c10004.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(eg,REASON_EFFECT)
if not c:IsRelateToEffect(e) or c:IsFacedown() then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e1:SetReset(RESET_EVENT+0x1ff0000)
e1:SetValue(500)
c:RegisterEffect(e1)
end
end
--レッド・ジャイアント
function c10011.initial_effect(c)
--end battle phase
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(10011,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SSET)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c10011.spcon)
e1:SetTarget(c10011.target)
e1:SetOperation(c10011.operation)
c:RegisterEffect(e1)
end
function c10011.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(Card.IsControler,1,nil,tp)
end
function c10011.target(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c10011.operation(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c10011.filter),tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_ATTACK+POS_FACEUP_DEFENSE)
Duel.ConfirmCards(1-tp,g)
end
local ph=Duel.GetCurrentPhase()
if tp~=Duel.GetTurnPlayer() and ph>=PHASE_BATTLE_START and ph<=PHASE_BATTLE then
Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE,1)
end
end
こうですか?
function c1300.initial_effect(c)
--end battle phase
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1300,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SSET)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c1300.spcon)
e1:SetTarget(c1300.sptg)
e1:SetOperation(c1300.spop)
c:RegisterEffect(e1)
end
function c1300.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(Card.IsControler,1,nil,1-tp)
end
function c1300.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c1300.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
local ph=Duel.GetCurrentPhase()
if tp~=Duel.GetTurnPlayer() and ph>=PHASE_BATTLE_START and ph<=PHASE_BATTLE then
Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE,1)
else
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SKIP_BP)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
if Duel.GetTurnPlayer()~=tp and ph>PHASE_MAIN1 and ph<PHASE_MAIN2 then
e1:SetLabel(Duel.GetTurnCount())
e1:SetCondition(c1300.skipcon)
e1:SetReset(RESET_PHASE+PHASE_BATTLE+RESET_OPPO_TURN,2)
else
e1:SetReset(RESET_PHASE+PHASE_BATTLE+RESET_OPPO_TURN,1)
end
Duel.RegisterEffect(e1,tp)
end
end
function c1300.skipcon(e)
return Duel.GetTurnCount()~=e:GetLabel()
end
--ブラック・マジシャン(DM)
function c10020.initial_effect(c)
--Yugioh
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCost(c10020.cost)
e1:SetTarget(c10020.target)
e1:SetOperation(c10020.activate)
e1:SetCountLimit(1,10020)
e1:SetCondition(c10020.condition)
Duel.RegisterEffect(e1,0)
end
function c10020.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,1000) end
Duel.PayLPCost(tp,1000)
end
function c10020.cfilter(c,tp)
return c:IsType(TYPE_SPELL) and c:IsPreviousLocation(LOCATION_DECK) and c:IsPreviousPosition(POS_FACEUP)
and c:GetPreviousControler()==1-tp and c:GetPreviousSequence()~=5
end
function c10020.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c10020.cfilter,0,nil,tp)
end
function c10020.tgfilter(c)
return c:IsAbleToHand()
end
function c10020.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c10020.tgfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c10020.tgfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=Duel.SelectTarget(tp,c10020.tgfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,sg,sg:GetCount(),0,0)
end
function c10020.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tc)
end
end
>>547
発動する効果の場合何処を直せばいいんですかね?
あと[string"./script/c10020.lua"]:24:attempt to index local ’eg’(a nil value)のエラーが出ちゃいました。意味を教えて頂ければ助かります。出来れば解決策も…
SetRangeは見つかりました。ありがとうございます
質問多くてすみません!回答よろしくお願いします!