5E Product Walkthrough Playlist
  1. #1
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4

    Manipulating Sources..

    So I'm working on this problem where a primary number value can be reduced by a source value, but only if the primary value remains greater than a given number.

    I tried setting up an onValueChanged() function in the primary value to check if it goes under the number and it works but when I do a setValue() on the source to remove it, it fails to updated the primary value, leaving the primary value adjusted. I'm guessing that I'm doing the wrong call to make that happen and thus avoiding the source adjusting code.
    Code:
    function onValueChanged()
    	local nodeWeapon = getDatabaseNode().getChild("....");
    	if getValue() < 50 then
    		DB.setValue(nodeWeapon, source[3]["name"][1], "number", 0);
    	end
    end
    Anyone have some suggestions?
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  2. #2
    Why don't you just add <min>50</min> to the number control?

  3. #3
    Also, if the control is a numberfield (i.e. linked to a node in the database) then you probably want to be setting the value on the control, not directly on the node? Maybe? Or does that set up an infinite recursion through onValueChanged?

    I still think you're better off just setting the min and max values you allow in the control, unless I misunderstand what the logic needs to be.
    Last edited by darrenan; April 27th, 2020 at 18:10.

  4. #4
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    Is that min value going to work if the control is being changed by a source?
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  5. #5
    Quote Originally Posted by Blackfoot View Post
    So I'm working on this problem where a primary number value can be reduced by a source value, but only if the primary value remains greater than a given number.

    I tried setting up an onValueChanged() function in the primary value to check if it goes under the number and it works but when I do a setValue() on the source to remove it, it fails to updated the primary value, leaving the primary value adjusted. I'm guessing that I'm doing the wrong call to make that happen and thus avoiding the source adjusting code.
    Code:
    function onValueChanged()
    	local nodeWeapon = getDatabaseNode().getChild("....");
    	if getValue() < 50 then
    		DB.setValue(nodeWeapon, source[3]["name"][1], "number", 0);
    	end
    end
    Anyone have some suggestions?

    DB.setValue(nodeWeapon, source[3]["name"][1], "number", 0);

    What is "source" there? Have you output that in debug to see what it actually is?
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  6. #6
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    Sure.. it is the info for the sources for that control... it inherits number_linked from CoreRPG... source is a variable in that template.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  7. #7
    Quote Originally Posted by Blackfoot View Post
    Sure.. it is the info for the sources for that control... it inherits number_linked from CoreRPG... source is a variable in that template.
    If you're certain that is correct... What is the "primary" value you are talking about and what is the Source you are changing.

    If they are the same, have you tried and use the "minimum" setting mentioned above?

    Sorry, the smallish clip of code is making it difficult for me to get a handle on what you're trying to do.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  8. #8
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    If you don't work with the number_linked template then you probably won't have the answer I'm looking for here.
    'number_linked' is the 'common' template that allows CoreRPG controls to talk to each other and share data behind the scenes.
    You can set a <source> in a control and tell it how that source relates to your control, then that second value will be added or subtracted from your initial control. I was kinda hoping to talk with someone who worked with this template a good bit and was familiar with it's nuances.
    In my situation.. the primary value is your 'skill', it could be a number between 0% and 200% or more, and the secondary value is based on how you want to split your skill up... assuming you can keep at least 50% in the primary skill... so I'm subtracting the 'source'.. which is the number you want to reduce your skill by in order to increase a 3rd number, your 'split' value. The check I'm working on is the one that prevents you from taking 151 from your skill of 200... 150 would be ok.. but 151 is right out. My plan is to bounce those entries entirely... which my code snip does.. kinda. What it doesn't do is undo what the number_linked code does... that is.. if you tell the primary value to reset itself... which honestly.. I assumed would happen when the source changed.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

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