peteralto
Member
- Joined
- Nov 1, 2020
- Messages
- 116
- Solutions
- 1
- Reaction score
- 22
I'm trying to insert a check inside the onMoveItem player. I would like to prevent the player from moving an item from the ring slot to a container that has the term dead in the name.
I tried the following code:
Apparently the check works, but when trying to move the item to a tile, for example, I am blocked and receive an error:
I tried the following code:
LUA:
if fromPosition.y == CONST_SLOT_RING and toCylinder then
local isContainerOrCorpse = toCylinder:isContainer() or toCylinder:isCorpse()
if isContainerOrCorpse then
local containerName = toCylinder:getName()
if containerName and string.find(containerName:lower(), "dead") then
return false
end
end
end
Apparently the check works, but when trying to move the item to a tile, for example, I am blocked and receive an error:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua: Player@onMoveItem
...ata\scripts\eventcallbacks\player\default_onMoveItem.lua:87: attempt to call method 'isContainer' (a nil value)