a place for all your custom card needs you can post scripts pics and request for card to be made also please donate to the funding for a new server made for custom card duels
 
HomePortalCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | .
 

 Lightforce Sword - Help Required (Solved)

View previous topic View next topic Go down 
AuthorMessage
DactylicMonster

avatar


Member Title : DactCoder
Posts : 7
Join date : 2015-01-21

PostSubject: Lightforce Sword - Help Required (Solved)   Thu Jan 22, 2015 9:29 am

I have been making anime cards, got in a few hundred.
Now I am totally lost/stuck on Lightforce Sword.

The following script is what I have, the problems occur at line 46.
At line 46 the script has an error processing " attempt to call method RegisterEffect (a nil value)".

Code:
1 --光の封札剣
2 function c49587034.initial_effect(c)
3 --Activate
4 local e1=Effect.CreateEffect(c)
5 e1:SetCategory(CATEGORY_REMOVE)
6 e1:SetType(EFFECT_TYPE_ACTIVATE)
7 e1:SetCode(EVENT_FREE_CHAIN)
8 e1:SetHintTiming(0,TIMING_TOHAND)
9 e1:SetTarget(c49587034.target)
10 e1:SetOperation(c49587034.activate)
11 c:RegisterEffect(e1)
12 end
13 function c49587034.target(e,tp,eg,ep,ev,re,r,rp,chk)
14 if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0
15 and Duel.IsExistingMatchingCard(nil,tp,LOCATION_HAND,0,1,nil) end
16 Duel.Hint(HINT_SELECTMSG,tp,564)
17 local ac=Duel.AnnounceCard(tp)
18 e:SetLabel(ac)
19 e:GetHandler():SetHint(CHINT_CARD,ac)
20 end
21 function c49587034.activate(e,tp,eg,ep,ev,re,r,rp)
22 local ac=e:GetLabel()
23 local g=Duel.GetMatchingGroup(Card.IsCode,tp,0,LOCATION_HAND,nil,ac)
24 local hg=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
25 Duel.ConfirmCards(tp,hg)
26 if g:GetCount()>1 then
27 Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
28 local sg=g:Select(tp,1,1,nil)
29 Duel.HintSelection(sg)
30 Duel.Remove(sg,POS_FACEUP,REASON_EFFECT)
31 else Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
32 end
33 if g==nil then return end
34 Duel.ShuffleHand(1-tp)
35 local ph=Duel.GetCurrentPhase()
36 local cp=Duel.GetTurnPlayer()
37 local e1=Effect.CreateEffect(e:GetHandler())
38 e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
39 e1:SetRange(LOCATION_REMOVED)
40 e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
41 e1:SetCountLimit(1)
42 e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,4)
43 e1:SetCondition(c49587034.thcon)
44 e1:SetOperation(c49587034.thop)
45 e1:SetLabel(0)
46 g:RegisterEffect(e1)
47 e:GetHandler():RegisterFlagEffect(1082946,RESET_PHASE+PHASE_END+RESET_SELF_TURN,0,3)
48 c49587034[e:GetHandler()]=e1
49 end
50 function c49587034.thcon(e,tp,eg,ep,ev,re,r,rp)
51 return Duel.GetTurnPlayer()==tp
52 end
53 function c49587034.thop(e,tp,eg,ep,ev,re,r,rp)
54 local ct=e:GetLabel()
55 e:GetOwner():SetTurnCounter(ct)
56 if ct==3 then
57 Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT)
58 e:GetOwner():ResetFlagEffect(1082946)
59 else
60 e:SetLabel(ct+1)
61 end
62 end
63

The script is trying to give an effect to a banished card (just like how Gold Sarcophagus works), but the game won't register the effect as it says, " attempt to call method RegisterEffect (a nil value) "

A problem like this hasn't occurred to me before; I've never had a problem with registering effects.

Thanks to anyone for any help.

~Edit:
Re-scripted the entire card, and eventually got it. Just needed to figure out how to get a value to store the card info (code) to run the RegisterEffect to the card.

If anyone finds and/or wants it:

Code:
--光の封札剣
function c49587034.initial_effect(c)
 --Activate
 local e1=Effect.CreateEffect(c)
 e1:SetCategory(CATEGORY_REMOVE)
 e1:SetType(EFFECT_TYPE_ACTIVATE)
 e1:SetCode(EVENT_FREE_CHAIN)
 e1:SetHintTiming(0,TIMING_END_PHASE)
 e1:SetTarget(c49587034.target)
 e1:SetOperation(c49587034.activate)
 c:RegisterEffect(e1)
end
function c49587034.target(e,tp,eg,ep,ev,re,r,rp,chk)
 if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_HAND,1,nil) end
 Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_HAND)
 Duel.Hint(HINT_SELECTMSG,tp,564)
 local ac=Duel.AnnounceCard(tp)
 e:SetLabel(ac)
 e:GetHandler():SetHint(CHINT_CARD,ac)
end
function c49587034.activate(e,tp,eg,ep,ev,re,r,rp)
 local ac=e:GetLabel()
 local card=Duel.GetMatchingGroup(Card.IsCode,tp,0,LOCATION_HAND,nil,ac)
 local hg=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
 local tg=card:GetFirst()
 Duel.ConfirmCards(tp,hg)
 Duel.ShuffleHand(1-tp)
 if tg==nil then return end
 if Duel.Remove(tg,POS_FACEUP,REASON_EFFECT)>0 then
 local ph=Duel.GetCurrentPhase()
 local cp=Duel.GetTurnPlayer()
 local e1=Effect.CreateEffect(e:GetHandler())
 e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
 e1:SetRange(LOCATION_REMOVED)
 e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
 e1:SetCountLimit(1)
 e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,3)
 e1:SetCondition(c49587034.thcon)
 e1:SetOperation(c49587034.thop)
 e1:SetLabel(1)
 tg:RegisterEffect(e1)
 e:GetHandler():RegisterFlagEffect(1082946,RESET_PHASE+PHASE_END+RESET_SELF_TURN,0,2)
 c49587034[e:GetHandler()]=e1
 end
end
function c49587034.thcon(e,tp,eg,ep,ev,re,r,rp)
 return Duel.GetTurnPlayer()==tp
end
function c49587034.thop(e,tp,eg,ep,ev,re,r,rp)
 local ct=e:GetLabel()
 e:GetOwner():SetTurnCounter(ct)
 if ct==3 then
 Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT)
 e:GetOwner():ResetFlagEffect(1082946)
 else
 e:SetLabel(ct+1)
 end
end




Last edited by DactylicMonster on Fri Jan 23, 2015 1:47 am; edited 1 time in total (Reason for editing : Fixed Issues)
Back to top Go down
View user profile
 

Lightforce Sword - Help Required (Solved)

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» [WIP] Hired Sword: Black Orc Overseer
» WYSIWYG sword
» Warlock (hired sword) - Does his staff count as Weapon ?
» The Sword in the Stone
» Excalibur and Extra Sword.

Permissions in this forum:You cannot reply to topics in this forum
Mackpro :: MackPro :: Custom Cards-