DICE PACKS BUNDLE
Page 87 of 109 First ... 3777858687888997 ... Last
  1. #861
    Quote Originally Posted by drvolk View Post
    Yeah, i will search the forum for an example of a subwindow with a datasource defined to verfify that. Thanks for your tips!
    I just realized the subwindow control shouldn't have the source property:

    Captura de pantalla 2022-07-08 001256.png

    I'll fix it in the next update.
    Ruleset Wizard
    The Ruleset Development Environment
    www.rulesetwizard.com
    Ruleset Wizard Tutorials
    Damned's Ruleset Wizard Tutorials

  2. #862
    I have been perusing the various videos, and have managed to make what I feel like is pretty decent progress using this software considering I have almost no experience with coding of any kind. The various videos posted by psicodelix, damned, and frostbyte have been a huge help.

    My biggest struggle has been understanding and implementing global variables and modifiers. I have been digging through code, and have managed to figure out bits and pieces, but am unable to actually make anything work.

    The short of it is that I was hoping that I had missed a video or tutorial on how to automate turning an ability score into a modifier and applying that modifier across the character sheet. Some of the videos I have come across implement a version of this on the same tab of the character sheet, but don't show how to get my Strength modifier into my damage roll on the Combat tab or my Intelligence score onto my Skills tab.

    Any direction or help would be greatly appreciated.

    Thanks!

  3. #863
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Hi Tenebris

    Its hard to give you specific advice with the info provided.

    Example 1.
    Create 2 number fields str and strmod
    on str and some code in the function onValueChanged() that looks something like this:
    Code:
    function onValueChanged()
      nScore = getValue();
      sName = getName();
      nodeChar = window.getDatabaseNode();
    
      DB.setValue(nodeChar, sName .. "mod", "number", nScore-10);
    end
    ofc you will need to create your own formula for calculating the modifier.

    make strmod readonly and add the following code:
    Code:
    function onDoubleClick(x, y)
      local nStart, nEnd, attName = string.find(getName(), "(%a%a%a).*")
      attName = string.upper(attName);
      ModifierStack.addSlot(attName, getValue());
    end
    when you double click that field it will add its value to the ModStack

    Example 2
    On your weapons attack roll add something like this:
    Code:
    function onBeforeDiceRoll()
      local nodeWeapon = window.getDatabaseNode();
      local nodeChar = window.getDatabaseNode().getParent().getParent();
      local nStrMod = nodeChar.getChild("strmod").getValue();
      DiceRollString ="1d20+" .. nStrMod;
    	
      return true;
    end
    I dont think you need global variables in most instances - just use local variables and call the data when you need it.
    These are just examples and probably wont meet your exact needs but will hopefully get you on the right track.

  4. #864
    Damned,

    I appreciate the response. I am a bit delayed in responding because I have been trying to put your suggestions into action. I have actually been extremely successful in getting several aspects of my ruleset build into practice, such as calculating encumbrance and max weight values, that have been something of a thorn in my side.

    What you provided ended up allowing my to make a great deal of forward progress in a few areas, but I actually ended up using some of the code that you had provided in one of your videos because it just seemed to make more sense in my head (hopefully I am not using it incorrectly). However, on my end, many things are looking the way I want them to:

    Code:
    function onValueChanged()
    	local nodeWin = window.getDatabaseNode();
    	local nScore = nodeWin.getChild("agility").getValue()
    	
    	if nScore <= 5 then
    		nBonus = 0;
    	elseif nScore <= 10 then
    		nBonus = 1;
    	elseif nScore <= 15 then
    		nBonus = 2;
    	elseif nScore <= 20 then
    		nBonus = 3;
    	elseif nScore <= 25 then
    		nBonus = 4;
    	elseif nScore <= 30 then
    		nBonus = 5;
    
    	end
    	
    	nodeWin.getChild("init").setValue(nBonus); 
    	nodeWin.getChild("movebonus").setValue(nBonus); 
    	
    end
    The issue I am having right now is converting the functioning code above into a function code for die variables in my die fields with onValueChanged(). onInit() works, but it also requires that the campaign be restarted, which is not ideal. I am hoping that the answer is obvious, but am afraid it is not possible. Functions like reset() or setdice() seem like they make sense for this purpose, but they don't work with any implementation I have tried.

    Code:
    function onInit()
    	local nodeWin = window.getDatabaseNode();
    	local nScore = nodeWin.getChild("endurance").getValue()
    	
    	if nScore <= 5 then
    		nHealth = "d3";
    	elseif nScore <= 10 then
    		nHealth = "d4";
    	elseif nScore <= 15 then
    		nHealth = "d6";
    	elseif nScore <= 20 then
    		nHealth = "d8";
    	elseif nScore <= 25 then
    		nHealth = "d10";
    	elseif nScore <= 30 then
    		nHealth = "d12";
    
    	end
    	
    	nodeWin.getChild("healthdie").setValue(nHealth); 
    	
    end

  5. #865
    Try this as the endurance onValueChanged:

    Code:
    function onValueChanged()
        local nScore = getValue()
        
        if nScore <= 5 then
            nHealth = {"d3"};
        elseif nScore <= 10 then
            nHealth = {"d4"};
        elseif nScore <= 15 then
            nHealth = {"d6"};
        elseif nScore <= 20 then
            nHealth = {"d8"};
        elseif nScore <= 25 then
            nHealth = {"d10"};
        elseif nScore <= 30 then
            nHealth = {"d12"};
        end
        
        window.healthdie.setDice(nHealth); 
    end
    the setDice function expects a table as the parameter, so you must use {} to create the dice values.

    This sample uses control references, you could need to use database references depending on your set up.
    Ruleset Wizard
    The Ruleset Development Environment
    www.rulesetwizard.com
    Ruleset Wizard Tutorials
    Damned's Ruleset Wizard Tutorials

  6. #866
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Also its common to do something like this:

    Code:
    function onInit()
      onValueChanged();
    end
    
    function onValueChanged()
      your code here;
    end
    then it runs the onValueChanged() at init as well as when the source changes
    I think that is what you are getting at...

  7. #867
    Thanks so much for your help; I will try to not abuse the privilege. I have everything working on the main tab pretty much how I want it and am working my way through completing the rest of the character sheet, adding in sidebar options, and tweaking the ps and ct. I know many of the videos you all have posted have answered a number of my questions, so I will try to look to those before I hassle you all any further.

  8. #868

  9. #869
    I took a hiatus from working on a project, the dice boxes worked then, but now I get this error;

    [ERROR] Script execution error: [string "RulesetWizardDiceRoller.lua"]:41: attempt to call field 'getActor' (a nil value).

    Any help would be appreciated.

  10. #870
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    getActor has been deprecated (by Fantasy Grounds not by the RSW)

    you need to replace
    ".getActor("pc", "
    with
    ".resolveActor("
    without the quotes
    and the same for
    ".getActor("npc", "

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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
  •  
STAR TREK 2d20

Log in

Log in