FG Spreadshirt Swag
  1. #1

    Applying rest not working

    I am working on a little extension that lets me rest a player from the CT...

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

    Code:
    		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...

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    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.

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Also, is this code running on the GM side, player side, or both?
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  4. #4
    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...
    Last edited by Diablobob; July 19th, 2019 at 00:57.

  5. #5

  6. #6
    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:

    Code:
    		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

  7. #7
    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!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in