PDA

View Full Version : performMultiAction or ActionsManager.performMultiAction?



Xarxus
February 14th, 2023, 17:52
This is probably a rookie question, I apologize in advance.

This code comes from CoreRPG, file manager_actions.lua, named ActionsManager in base.xml.
Inside the function performAction there is a call to ActionsManager.performMultiAction, which is
the function below. Why was it qualified? Is it the same calling it without ActionsManager qualifier?

function performAction(draginfo, rActor, rRoll)
if not rRoll then
return;
end

ActionsManager.performMultiAction(draginfo, rActor, rRoll.sType, { rRoll });
end

function performMultiAction(draginfo, rActor, sType, rRolls)
if not rRolls or #rRolls < 1 then
return false;
end

if draginfo then
ActionsManager.encodeActionForDrag(draginfo, rActor, sType, rRolls);
else
ActionsManager.actionDirect(rActor, sType, rRolls);
end
return true;
end

Jiminimonka
February 14th, 2023, 18:41
This is probably a rookie question, I apologize in advance.

This code comes from CoreRPG, file manager_actions.lua, named ActionsManager in base.xml.
Inside the function performAction there is a call to ActionsManager.performMultiAction, which is
the function below. Why was it qualified? Is it the same calling it without ActionsManager qualifier?

function performAction(draginfo, rActor, rRoll)
if not rRoll then
return;
end

ActionsManager.performMultiAction(draginfo, rActor, rRoll.sType, { rRoll });
end

function performMultiAction(draginfo, rActor, sType, rRolls)
if not rRolls or #rRolls < 1 then
return false;
end

if draginfo then
ActionsManager.encodeActionForDrag(draginfo, rActor, sType, rRolls);
else
ActionsManager.actionDirect(rActor, sType, rRolls);
end
return true;
end
Just a guess but MultiAction is a Savage Worlds option on Combat.

damned
February 14th, 2023, 23:30
If you are calling the second function from within the same file I dont think it needs to be qualified but if the first function is being called from outside the file and it is calling the second function then I think it does need to be qualified...

Moon Wizard
February 15th, 2023, 00:04
If you are calling the exact instance of a function in the same file, then you do not need to qualify the name as it will use the locally defined version.

However, if an extension attempts to override a function (i.e. ActionsManager.performMultiAction = myOverrideFunction); then not qualifying the name would prevent the new function from being called by any other code in that file. By defining indirectly (i.e. with the name), then extensions can override a single function without having to override the whole file.

Regards,
JPG

Xarxus
February 15th, 2023, 10:07
You comfort me, it wasn't such a silly question back then