Major bug with Monster.addItem().
Posted: Sat Mar 07, 2015 7:59 pm
I am wondering if this got introduced in the latest beta, not sure. But for there is a problem now. Monster:addItem() is not taking the item off surface components.
I am getting a monster to take an item out of a chest. This is my exact code to do that:
Ignore "bd.holdableObjects". The monster is only allowed to take out certain items. The key is in this table and he does take the key (the only key) out of the chest.
Later, he choses to go back to the chest and take anything in there out again. The exact same code executes. What should happen is chestGO.surface:contents() should not be returning any more objects since he already took the key out. But the key is still there. And he takes it again!! The exact same key.
I kill the monster and the game blows up because it tries to put two identical keys on the ground. Its bugged.
Error:
I am going look for a work around but needless to say I am bummed.
I am getting a monster to take an item out of a chest. This is my exact code to do that:
Code: Select all
for i, item in chestGO.surface:contents() do
for j, id in ipairs(bd.holdableObjects) do
if item.go.id == id then
print("Monster: "..brain.go.id.." is taking key: "..item.go.id.." out of chest")
brain.go.monster:addItem(item)
end
end
end
Later, he choses to go back to the chest and take anything in there out again. The exact same code executes. What should happen is chestGO.surface:contents() should not be returning any more objects since he already took the key out. But the key is still there. And he takes it again!! The exact same key.
I kill the monster and the game blows up because it tries to put two identical keys on the ground. Its bugged.
Error:
Code: Select all
[string "Map.lua"]:0: entity already added to map
stack traceback:
[C]: in function 'assert'
[string "Map.lua"]: in function 'addEntity'
[string "Monster.lua"]: in function 'dropItem'
[string "Monster.lua"]: in function 'dropAllItems'
[string "Monster.lua"]: in function 'die'
[string "GameMode.lua"]: in function 'keyPressed'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk