PDA

View Full Version : CoreRPG WindowManager suggestion



Zarestia
February 28th, 2023, 15:05
I'm not really sure where to post this...

The new ordering mechanism for power actions broke one of my extensions which added power actions directly to the spell record window. Players could now longer open spell records without receiving errors.

The culprit lies in the manager_window.lua script, which sets an order node to a node not owned by the executing session (player in this regard):


function setInitialOrder(w)
if not w or not w.windowlist then
return;
end

local node = w.getDatabaseNode();
if not node or (DB.getValue(node, "order", 0) ~= 0) then
return;
end

local tOrder = {};
for _,v in ipairs(DB.getChildList(w.windowlist.getDatabaseNod e(), "")) do
tOrder[DB.getValue(v, "order", 0)] = true;
end
local i = 1;
while tOrder[i] do
i = i + 1;
end

DB.setValue(node, "order", "number", i);
end

I suggest to add an additional check whether the node is actually owned and can be written to, like this:


function setInitialOrder(w)
if not w or not w.windowlist then
return;
end

local node = w.getDatabaseNode();
if not node or (DB.getValue(node, "order", 0) ~= 0) or not DB.isOwner(node) then
return;
end

local tOrder = {};
for _,v in ipairs(DB.getChildList(w.windowlist.getDatabaseNod e(), "")) do
tOrder[DB.getValue(v, "order", 0)] = true;
end
local i = 1;
while tOrder[i] do
i = i + 1;
end

DB.setValue(node, "order", "number", i);
end


For the meantime, I overwrite the CoreRPG script like this but it would be nice to get it working without me fiddling in deep CoreRPG functions.

Moon Wizard
February 28th, 2023, 18:15
This is part of the update for CoreRPG today.

JPG