data/scriptslocal action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("Doing something.")
return true
end
-- choose 1
action:aid(45001) -- can be put on multiple objects
action:uid(45001) -- can be put on a single object. (unique)
action:id(111111) -- triggers when an item with this itemid is clicked / interacted with.
action:register()
data/scriptslocal action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("Doing something.")
return true
end
-- choose 1
action:aid(45001) -- can be put on multiple objects
action:uid(45001) -- can be put on a single object. (unique)
action:id(111111) -- triggers when an item with this itemid is clicked / interacted with.
action:register()
got 1 more small question is it possible to move the corpse from onDropLootMost common method is using an ActionId or UniqueId on the object the player is going to interact with.
Less favourable method would be using the itemId of the object.
In both scenario's above, this would be scripted as an Action event.
data/scripts
LUA:local action = Action() function action.onUse(player, item, fromPosition, target, toPosition, isHotkey) print("Doing something.") return true end -- choose 1 action:aid(45001) -- can be put on multiple objects action:uid(45001) -- can be put on a single object. (unique) action:id(111111) -- triggers when an item with this itemid is clicked / interacted with. action:register()
function Monster:onDropLoot(corpse)
if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
end
end
You'd have to explain what you're trying to do.thank you <3
Post automatically merged:
got 1 more small question is it possible to move the corpse from onDropLoot
LUA:function Monster:onDropLoot(corpse) if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse) end end
to the onUse that u showed ?
Im trying to just change the sprites, when player dies chest appears and when somebody clicks/opens the corpse(chest) the sprite changes into the open sprites but when i do this with onUse the corpse loses the owner and everybody can open itYou'd have to explain what you're trying to do.
While there might not be a direct way to do what you're intending, we can probably figure out something / workaround.
item:hasAttribute(key)
item:getAttribute(key)
item:setAttribute(key, value) -- value would likely need to be a player
item:removeAttribute(key)
ITEM_ATTRIBUTE_CORPSEOWNER -- this would be the key
item:transform would remove the ownsership value.Its because decaying items use transform. So all corpse would never remove ownership at any state. Once a body decays (transforms) the first time it removes the ownership.Try using these functions to set/remove ownership
LUA:item:hasAttribute(key) item:getAttribute(key) item:setAttribute(key, value) -- value would likely need to be a player item:removeAttribute(key) ITEM_ATTRIBUTE_CORPSEOWNER -- this would be the key
That being said, I'm surprised that transforming an objectitem:transformwould remove the ownsership value.
Strange.
void Game::internalDecayItem(Item* item)
{
const ItemType& it = Item::items[item->getID()];
if (it.decayTo != 0) {
Item* newItem = transformItem(item, item->getDecayTo());
startDecay(newItem);
} else {
ReturnValue ret = internalRemoveItem(item);
if (ret != RETURNVALUE_NOERROR) {
std::cout << "[Debug - Game::internalDecayItem] internalDecayItem failed, error code: " << static_cast<uint32_t>(ret) << ", item id: " << item->getID() << std::endl;
}
}
}