Svira
Active Member
- Joined
- Jan 27, 2008
- Messages
- 269
- Solutions
- 11
- Reaction score
- 37
Hello, please help me how to correctly read the attackspeed of a weapon?
yes, yes I have it added to src.
error: attempt to perform artihmetic on a nil value
TFS 1.2 - 8.0
code:
yes, yes I have it added to src.
error: attempt to perform artihmetic on a nil value
TFS 1.2 - 8.0
code:
Lua:
local attrkeys = {
['charges'] = ITEM_ATTRIBUTE_CHARGES,
['time'] = ITEM_ATTRIBUTE_DURATION,
['atk'] = ITEM_ATTRIBUTE_ATTACK,
['atk speed'] = ITEM_ATTRIBUTE_ATTACKSPEED,
['def'] = ITEM_ATTRIBUTE_DEFENSE,
['extra def'] = ITEM_ATTRIBUTE_EXTRADEFENSE,
['arm'] = ITEM_ATTRIBUTE_ARMOR,
['accuracy'] = ITEM_ATTRIBUTE_HITCHANCE,
['range'] = ITEM_ATTRIBUTE_SHOOTRANGE
}
function Item.addStat(item, spellname, spellvalue, suffix, cid)
if isInArray({'charges', 'time', 'atk', 'atk speed', 'def', 'extra def', 'arm', 'accuracy', 'range'}, spellname) then
local basestats = item:getBaseStatsInfo()
local basestats2 = {
['charges'] = basestats.charges,
['time'] = basestats.duration,
['atk'] = basestats.attack,
['atk speed'] = basestats.attackSpeed,
['def'] = basestats.defense,
['extra def'] = basestats.extraDefense,
['arm'] = basestats.armor,
['accuracy'] = basestats.hitChance,
['range'] = basestats.shootRange
}
local uid = item:getUniqueId()
local fullstats = {
['charges'] = getItemAttribute(uid, ITEM_ATTRIBUTE_CHARGES),
['time'] = item:getBaseDuration(),
['atk'] = getItemAttribute(uid, ITEM_ATTRIBUTE_ATTACK),
['atk speed'] = getItemAttribute(uid, ITEM_ATTRIBUTE_ATTACKSPEED),
['def'] = getItemAttribute(uid, ITEM_ATTRIBUTE_DEFENSE),
['extra def'] = getItemAttribute(uid, ITEM_ATTRIBUTE_EXTRADEFENSE),
['arm'] = getItemAttribute(uid, ITEM_ATTRIBUTE_ARMOR),
['accuracy'] = getItemAttribute(uid, ITEM_ATTRIBUTE_HITCHANCE),
['range'] = getItemAttribute(uid, ITEM_ATTRIBUTE_SHOOTRANGE)
}
if suffix == "%" then
if basestats2[spellname] == 0 then
if cid then
Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, "Spell " .. spellname .. "% is not available for this item.")
end
return false
end
item:setAttribute(attrkeys[spellname], fullstats[spellname] + math.abs(math.floor((basestats2[spellname] * spellvalue/100)))) -- error here
else
item:setAttribute(attrkeys[spellname], fullstats[spellname] + math.abs(spellvalue)) -- or here
end
end
item:addStatSlot(spellname, spellvalue, suffix)
return true
end