FG Spreadshirt Swag
Page 1 of 4 123 ... Last
  1. #1

    Buttongroup_counter

    I am using the buttongroup_counter template on the main desktop.

    It looks great, and loads correct. The problem is, in the onInit, there is this section:

    Code:
    	-- Synch to the data nodes
    	local nodeWin = window.getDatabaseNode();
    	if nodeWin then
    		local sLoadMaxNodeName = "";
    		local sLoadCurrNodeName = "";
    		
    		if sourcefields then
    			if sourcefields[1].maximum then
    				sLoadMaxNodeName = sourcefields[1].maximum[1];
    			end
    			if sourcefields[1].current then
    				sLoadCurrNodeName = sourcefields[1].current[1];
    			end
    		end
    		
    		if sLoadMaxNodeName ~= "" then
    			if not DB.getValue(nodeWin, sLoadMaxNodeName) then
    				DB.setValue(nodeWin, sLoadMaxNodeName, "number", 1);
    			end
    			setMaxNode(DB.getPath(nodeWin, sLoadMaxNodeName));
    		end
    		if sLoadCurrNodeName ~= "" then
    			setCurrNode(DB.getPath(nodeWin, sLoadCurrNodeName));
    		end
    	end
    When I run the code, nodeWin comes up as nil for both player and host. How can I call this so that it will work for everyone?

    I was thinking of throwing that section into a separate function, and when host call it at one point, and when player, call it when char sheet opens. If I do that, I feel like I may need to create a different nodeWin for player and host, but I'm not sure if this will work or not. I don't know if it will be as simple as that, since the file also has a few other functions that will do a DB.getValue and DB.setValue. Any insight would be appreciated.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  2. #2
    Also, a thought, because this will have an effect on the dice roll, should I modify the buttongroup_counter.lua file and add the registerControl and updateControl functions from modifierstack.lua and then manipulate those somehow? If that is the answer, I will also need a little guidance. Basically, I want a 5 button system that just keeps track of a number 1 to 5, and when I roll the dice, I can then throw it into rRoll as another key value pair.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  3. #3
    OK, update on what I've done. I initially used the buttongroup_counter template as is, but I had two groups on the desktop. Different windowsclasses though. but when I made them both the buttongroup template, they seemed to be linked and when clicking one, the other would also increase or decrease. So, I separated them into two different templates and I made two copies of the lua file unique to the template. Now, it kinda works. First off, it would error out after the first click because under the setCurrentValue function was this:

    function setCurrentValue(nCount)
    if sCurrNodeName ~= "" then
    DB.setValue(sCurrNodeName, "number", nCount);
    else
    nLocalCurrent = nCurrent;
    end
    end
    This was erroring out because this is the only place in the file nCurrent was listed, and I didn't know how to find it. So, I changed it from nCurrent to nCount. Now, with some Debugs I can see that the values increase and decrease separately and as expected, however, the pips themselves do not change. Whatever I change the current value to and reload is how many pips will be lit up, but they do not change from that state.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  4. #4
    I didn't quite follow if you still had questions, or whether you were just documenting the steps you went through. If you have questions, just call them out in a bulleted list or in some way that it's obvious and myself or the community can try to answer.

    Regards,
    JPG

  5. #5
    Sorry, I was not thinking of clearity as I was typing it up. I do still have questions.

    1) The line:
    local nodeWin = window.getDatabaseNode();
    is throwing an error because it is on the desktop, and not in a window. Should I split it into two separate commands, one for host and one for player, or is there something I could put there to make it work for both?

    2) the buttons are showing up and whatever I have the starting value at is what buttons are on and what are off (staring value of 2, first two are checked on last 3 are not). When I debug and click on them, the debug tells me the actual value that it should be, but the icons are not updating. How do I fix that?

    3) Once I get this fixed, I want to be able to be able to add these as a key value pair to rRoll, once I initiate the roll. How do I do that? I assume it would be similar to the nMod pair, but I can't find where in the system that info is collected. Any help on that would be appreciated.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  6. #6
    1) The controls on the desktop should still be encapsulated in a window instance. So, window.getDatabaseNode() should still work, and just return nil. What's the exact error message you are seeing in the console?

    2) The template was really built to support database-linked capability in a sheet to which the user has access. Since you are making your own, I would copy the template and script; and modify what you need.

    Since it is not linked to the database, you'll need to call the update() function for the control manually after changing either the current or max values, in order for the template to update it's visual display. That's what the addHandler/removeHandler functions set up to do automatically when this template is database-linked.

    If this control is meant to be mirrored in values on both host and player, then you can create a global database node to hold the values; and have the template linked that way. Of course, since only one user can own a database node at a time, the reality is that only the GM will be able to update the values. If you want something that either the GM or players can update independently of each other, that's more complex, and would require OOB messaging to set that up.

    If this control is meant to be unique in values for each user, then you would want to rip out all the database stuff in your copied version of the template script; and just make the setMaxValue and setCurrentValue functions perform the update call directly.

    3) There is no place to inject values into a roll arbitrarily. You have to override the individual roll handling for rolls that are affected. This is how it's handled in the 5E ruleset for example to handle the ADV/DIS, +/-2, and +/-5 buttons.

    Regards,
    JPG

  7. #7
    Hello,

    Thank you for that help. I now have the physical buttons working. Here's a question to expand on #3. I know, if I type a number into the modifier box and then roll the dice, the system will add that number to the roll. From what I can tell, that box is not stored in the DB. I have been looking and having trouble finding the code that actually tells the system, if there is a number here, then use it as a modifier. I know it usually gets saved as rRoll.nMod, and then it is used however, once the roll is complete. But how does the system grab that number to then add it to the rRoll table? I looked in some action files, but I feel like I may be missing a step, as it doesn't seem complete. I also don't see any OOB messaging used for the modifier, unless that piece I'm missing uses it. I hope that makes sense, and I'm sorry if these are dumb questions.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  8. #8
    That code is embedded in the ModifierStack and ActionsManager global scripts within CoreRPG ruleset.

    As I mentioned, you should look at 5E, which has an example of pulling desktop button modifiers into rolls. See ActionsManager2.encodeDesktopMods(rRoll); calls throughout 5E ruleset.

    Regards,
    JPG

  9. #9
    So, further questions. Upon research, I found this under desktop_template.xml

    <script>
    local bInit = false;
    function onInit()
    if ModifierStack.getModifierKey(getName()) then
    setValue(1);
    end
    bInit = true;
    end
    function onValueChanged()
    if bInit then
    if getValue() ~= 0 then
    ModifierStack.setModifierKey(getName(), true);
    else
    ModifierStack.setModifierKey(getName(), false);
    end
    end
    end
    Debug.chat(bInit);
    </script>
    I believe this is what would work for a simple single state switch. How would I modify this to work with a row of 5 pips that turn on and off, like the 5 pips under the modifier window.
    Attached Images Attached Images
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  10. #10
    The ModifierStack built-in functionality only knows about whether a button is pressed or not; there's no concept of a multi-state like you're trying to do. You could implement as five different "keys" that are true/false, based on the value. However, you could just have your own custom global script to track this that you reference in the roll modification code.

    Regardless of how you do this, you will still need to handle this in your own custom roll modification code as mentioned in post #8 above.

    Regards,
    JPG

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