LeOnArd0
Member
- Joined
- Jan 24, 2010
- Messages
- 76
- Reaction score
- 14
Sup guys.
I have a question (TFS 1.5)
My idea is that the player who had a storage 15550, 1, spend 1 soul to cast any rune. If he has 15500, 0, he will not spend soul when casting the rune. I thought it better to add it directly to the function, right?
I'm having trouble fitting the rule and ensuring that if the player with storage 15550, 1 doesn't have > 1 soul, the rune is not conjured.
I tried some methods but it didn't work.
Original code:
If anyone can help me, please.
Thanks a lot!!
I have a question (TFS 1.5)
My idea is that the player who had a storage 15550, 1, spend 1 soul to cast any rune. If he has 15500, 0, he will not spend soul when casting the rune. I thought it better to add it directly to the function, right?
I'm having trouble fitting the rule and ensuring that if the player with storage 15550, 1 doesn't have > 1 soul, the rune is not conjured.
I tried some methods but it didn't work.
Original code:
Lua:
function Player:conjureItem(reagentId, conjureId, conjureCount, effect)
if not conjureCount and conjureId ~= 0 then
local itemType = ItemType(conjureId)
if itemType:getId() == 0 then
return false
end
local charges = itemType:getCharges()
if charges ~= 0 then
conjureCount = charges
end
end
if reagentId ~= 0 then
local left = self:getSlotItem(CONST_SLOT_LEFT)
local right = self:getSlotItem(CONST_SLOT_RIGHT)
local canConjure = false
if left and left:getId() == reagentId then
left:transform(conjureId, conjureCount)
canConjure = true
end
if right and right:getId() == reagentId then
right:transform(conjureId, conjureCount)
canConjure = true
end
if not canConjure then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
else
local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
self:getPosition():sendMagicEffect(effect and effect or CONST_ME_MAGIC_RED)
return true
end
2023-05-08_14-05-47.609252 Lua Script Error: [Spell Interface]
2023-05-08_14-05-47.609549 data/spells/scripts/conjuring/sudden_death_rune.luanCastSpell
2023-05-08_14-05-47.609752 data/spells/lib/spells.lua:272: attempt to index global 'player' (a nil value)
2023-05-08_14-05-47.609839 stack traceback:
2023-05-08_14-05-47.609895 [C]: in function '__index'
2023-05-08_14-05-47.610266 data/spells/lib/spells.lua:272: in function <data/spells/lib/spells.lua:271>
If anyone can help me, please.
Thanks a lot!!
Last edited: