Hello,
I have problem with loot from monster.
Console error:
events/scripts/monster.lua
scripts\eventcallbacks\monster\deflaut_onDropLoot.lua
Where is the problem?
I have problem with loot from monster.
Console error:
Code:
Lua Script Error: [Event Interface]
data/events/scripts/monster.lua:[email protected]
...ta\scripts\eventcallbacks\monster\default_onDropLoot.lua:13: attempt to call method 'createLootItem' (a nil value)
stack traceback:
[C]: in function 'createLootItem'
...ta\scripts\eventcallbacks\monster\default_onDropLoot.lua:13: in function <...ta\scripts\eventcallbacks\monster\default_onDropLoot.lua:3>
...1.4-Downgrades-8.60\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
data/events/scripts/monster.lua:3: in function <data/events/scripts/monster.lua:1>
events/scripts/monster.lua
Lua:
function Monster:onDropLoot(corpse)
if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
end
end
function Monster:onSpawn(position, startup, artificial)
if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
else
return true
end
end
scripts\eventcallbacks\monster\deflaut_onDropLoot.lua
Lua:
local ec = EventCallback
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()
for i = 1, #monsterLoot do
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
for i = corpse:getSize() - 1, 0, -1 do
local containerItem = corpse:getItem(i)
--local count = containerItem:getCount()
print(containerItem:getId())
end
if player then
local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
end
else
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
end
end
ec:register()
Where is the problem?