• 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!

Action IDs and Item IDs

Sam Drost

Intermediate OT User
Joined
May 29, 2017
Messages
88
Reaction score
118
I can't find this explicitly, but looking at the Lua scripts, it seems like and action id does not need to be unique across all items ids, but it does need to be unique across a single item id, and what the server does is when a player tries to use an item id, it checks to see if there is a script for that item id and passes the action id to the script. Is that essentially correct, or am I missing something?
 
Action id can be on any item at any time regardless of ID. When you use an item, it goes to Actions::internalUseItem, it checks if the item is scripted, if it is, it executes the onUse script.
From actions.cpp:
C++:
    Action* action = getAction(item);
    if (action) {
        if (action->isScripted()) {
            if (action->executeUse(player, item, pos, nullptr, pos, isHotkey)) {
                return RETURNVALUE_NOERROR;
            }

            if (item->isRemoved()) {
                return RETURNVALUE_CANNOTUSETHISOBJECT;
            }
        } else if (action->function) {
            if (action->function(player, item, pos, nullptr, pos, isHotkey)) {
                return RETURNVALUE_NOERROR;
            }
        }
    }

Same thing if you use an item on a target (crosshair items), but the called function is Actions::internalUseItemEx instead, but the same thing occurs in both functions.
 
Back
Top