chaosrider92
2014-08-25T01:47:16Z
Can anyone help me with this script? The problem is that when I choose to sacrifice 6400 or more LP, the program gives me an "Error Occured" message then kicks me out to the main menu. Any ideas?

Card Effect: When this card attacks or is attacked, you can pay LP (in increments of 100) to increase the ATK and DEF of this card by the LP you have paid until the end of the Damage Step.

Script:

function c47723119.initial_effect(c)
--Atk Up
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(47723119,0))
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE)
e1:SetCode(EVENT_BATTLE_START)
e1:SetCountLimit(1)
e1:SetCost(c47723119.atkcost)
e1:SetOperation(c47723119.atkop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_BE_BATTLE_TARGET)
c:RegisterEffect(e2)
end

function c47723119.atkcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,100) end
local lp=Duel.GetLP(tp)
local t={}
local f=math.floor((lp-1)/100)
local l=1
while l<=f do
t[l]=l*100
l=l+1
end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(47723119,0))
local announce=Duel.AnnounceNumber(tp,table.unpack(t))
Duel.PayLPCost(tp,announce)
e:SetLabel(announce)
end
function c47723119.atkop(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:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(e:GetLabel())
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_DAMAGE_CAL)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_UPDATE_DEFENCE)
c:RegisterEffect(e2)
end
end