• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua onDeath - How to set action id in corpse

allway

New Member
Joined
Apr 12, 2013
Messages
8
Reaction score
0
Location
Brasil
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    local tile = targetMonster:getPosition():getTile()
    local thing = tile:getTopVisibleThing()
    if thing:isItem() then
        thing:setActionId(3193)
    end

    return true
end

The above code does not work.
I did not find any example for this on the internet.
 
Last edited by a moderator:
Use the corpse item userdata provided.

Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    if corpse then
        corpse:setActionId(3193)
    end

    return true
end

Test it real quick, I feel like I made a mistake somewhere.
 
Yeah, forgot those items didn't get changed to userdata...

Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    local corpse = Container(corpse)
    if corpse then
        corpse:setActionId(3193)
    end

    return true
end
 
I did not know he had to declare global.

Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    local corpse = Item(corpse)
    if corpse then
        corpse:setActionId(3193)
    end

    return true
end

The above work with Item(corpse), but not with container(corpse)!
The corpse of this monster cannot be opened.

Thanks!
 
If the corpse is a container, both should work. If it's not a container, you need to use Item(). If it is a container and Container() didn't work, please file an issue because that's a bug.
 
Back
Top