PDA

View Full Version : Applying rest not working



Diablobob
July 18th, 2019, 21:22
I am working on a little extension that lets me rest a player from the CT...

However, I cannot get the rest function working...



if selection == 8 then
local nodeChar = getDatabaseNode();

local sClass, sRecord = DB.getValue(nodeChar, "link", "", "");
if sClass == "charsheet" and sRecord ~= "" then
local nodeRest = DB.findNode(sRecord);
end

if subselection == 8 then
ChatManager.Message(Interface.getString("message_restshort"), true, ActorManager.getActor("pc", nodeChar));
CharManager.rest(nodeRest, false);

elseif subselection == 6 then
ChatManager.Message(Interface.getString("message_restlong"), true, ActorManager.getActor("pc", nodeChar));
CharManager.rest(nodeRest, true);

end
end


I only want to apply the rest to the CT entry clicked on.

I have tried many ways of doing it... I can get CombatManager2.resetHealth to reset the HP and such... but HD and other upkeep on the character sheet are not adjusted as they should be...


Any help would be appreciated... I do not know why the CharManager.rest function is not working like it should with my script...

damned
July 19th, 2019, 00:07
First check if nodeChar is getting the value you think it is
Then i would check what the CharManager.rest is doing - it may be coded to look at the whole PS or CT - you may need to modify it or duplicate it as restSolo or similar.

Trenloe
July 19th, 2019, 00:53
Also, is this code running on the GM side, player side, or both?

Diablobob
July 19th, 2019, 00:55
I know it can handle solo instances... because the function call is the same as the one for the character sheet radial menu... of selected there, only that character will receive the rest...

I’m just trying to emulate the selection from the character sheet... but from the CT instead of the character sheet... but even pointing to the sheet itself, as the node, is not working...

Diablobob
July 19th, 2019, 00:56
GM only

Moon Wizard
July 19th, 2019, 00:59
You're defining nodeRest as a local variable within an if...end statement. That means the variable only exists within the if...end statement.

Try moving it outside the if statement, something like this:



if selection == 8 then
local nodeChar = nil;
local nodeCT = getDatabaseNode();
local sClass, sRecord = DB.getValue(nodeCT, "link", "", "");
if sClass == "charsheet" and sRecord ~= "" then
nodeChar = DB.findNode(sRecord);
end
if not nodeChar then return; end

if subselection == 8 then
ChatManager.Message(Interface.getString("message_restshort"), true, ActorManager.getActor("pc", nodeChar));
CharManager.rest(nodeChar, false);

elseif subselection == 6 then
ChatManager.Message(Interface.getString("message_restlong"), true, ActorManager.getActor("pc", nodeChar));
CharManager.rest(nodeChar, true);
end
end


Regards,
JPG

Diablobob
July 19th, 2019, 01:12
OMG!!!... it works!!!

I can’t believe I overlooked trapping the variable inside the if statement using “local”...

I am stupid sometimes!

thank you guys SOOOO MUCH!!! It has been bugging me all day long!!!

Thank you again!!!