Quote:
Originally Posted by neograsia
Thanks for the answer.. but..
Can you tell an example please. If I solve this problem... I will not ask any more questions. I promise :p
|
can try this but is not tested:
Code:
function apply_bonus(i, mode)
local a = {}
local bon = {}
local x = 1
local y = 2
local w = 1
local bonus
local PetGrade = tonumber(GetGrade(i))
while true do
a[x] = tonumber(data_tool(i, x, PET_BONUS, PET_READ))
if a[x] == nil then break end
x = x + 1
end
local z = tonumber(a[1])+2
while true do
bonus = tonumber(a[y])
bon[y-1] = PetBonus[z][y][bonus]
if bon[y-1] == nil then break end
y = y + 1
end
if mode == PET_SUMMON then
while true do
if bon[w] == nil then break end
affect.add_collect(bon[w], PetGrade, 60*60*8)
w = w + 1
end
elseif mode == PET_UNSUMMON then
while true do
if bon[w] == nil then break end
affect.remove_collect(bon[w], PetGrade, 60*60*8)
w = w + 1
end
end
end
or also this which is less beautiful but efficient
Code:
function apply_bonus(i, mode)
local PetGrade = tonumber(GetGrade(i))
local a = tonumber(data_tool(i, PET_BON1, PET_BONUS, PET_READ))
local b = tonumber(data_tool(i, PET_BON2, PET_BONUS, PET_READ))
local c = tonumber(data_tool(i, PET_BON3, PET_BONUS, PET_READ))
local d = tonumber(data_tool(i, PET_BON4, PET_BONUS, PET_READ))
local e = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ))
local bon1 = PetBonus[e+2][2][a]
local bon2 = PetBonus[e+2][3][b]
local bon3 = PetBonus[e+2][4][c]
local bon4 = PetBonus[e+2][5][d]
if mode == PET_SUMMON then
affect.add_collect(bon1, PetGrade, 60*60*8)
affect.add_collect(bon2, PetGrade, 60*60*8)
affect.add_collect(bon3, PetGrade, 60*60*8)
affect.add_collect(bon4, PetGrade, 60*60*8)
elseif mode == PET_UNSUMMON then
affect.remove_collect(bon1, PetGrade, 60*60*8)
affect.remove_collect(bon2, PetGrade, 60*60*8)
affect.remove_collect(bon3, PetGrade, 60*60*8)
affect.remove_collect(bon4, PetGrade, 60*60*8)
end
end