1. #1

    Modifying Characteristic Bonus Calculation in the MyQuest extension

    I've been using a customized MyQuest extension for some time now to make BRP behave more like Magic World with mostly success, but there is one niggling issue I haven't been able to figure out.

    Starting on line 256 in the "MyScript.lua" file there is a function for calculating characteristic bonuses for skills. Numerous times I've attempted to edit this section to make the characteristic bonus calculate according to Magic World rules (which is Characteristic/2) but no matter what I've done, it reverts to the default BRP characteristic bonus calculation.

    Here is the default code:
    Code:
    function getCategoryBonus(influence,characteristic)
      if influence=="Primary" then
        return characteristic - 10;
      elseif influence=="Secondary" then
        if characteristic>10 then
          return math.floor(characteristic/2) - 5;
        else
          return math.ceil(characteristic/2) - 5;
        end
      elseif influence=="Negative" then
        return 10 - characteristic;
      end
      return 0;
    end
    And here is the code I'm attempting to replace it with:
    Code:
    function getCategoryBonus(influence,characteristic)
      if influence=="Primary" then
        return math.ceil(characteristic/2);
      end
      return 0;
    end
    I'm certainly no code expert, so I suspect that I'm probably doing something wrong with the syntax, but the console doesn't seem to throw any errors, it just always defaults to the top calculation method, whenever I enable characteristic bonuses in the options.

    Any help would be appreciated.
    Last edited by FlightlessScotsman; April 21st, 2017 at 19:58.

  2. #2
    Update (sort of)

    On the plus I was able to verify that my code is correct.

    On the downside I had to directly edit a script in the Basic Roleplaying.pak, namely "charsheet_skilllist.lua with my code to get the character sheet to force it to recognize new calculation function. I gather that this means I will lose any edits any time I happen to run an update and the BRP ruleset will get overwritten with the server version. I considered just copying the .pak file and renaming it something like BRP-MW.pak, but if I do that I won't be able to load any of the BRP modules that come with the ruleset.

    If anybody has any great insight on how to force charsheet_skilllist.lua to respect the overrides in the MyQuest extension I'd love to hear it.
    Last edited by FlightlessScotsman; April 21st, 2017 at 23:02.

  3. #3
    You have to redefine the control or template which defines the script within your extension, and include the updated script file under a "scripts" subdirectory in the extension.

    Code:
      <windowclass name="charsheet_skills" merge="join">
        <sheetdata>
          <windowlist name="skilllist">
            <script file="scripts/charsheet_skilllist.lua" />
          </windowlist>
        </sheetdata>
      </windowclass>
    Regards,
    JPG

  4. #4
    Quote Originally Posted by Moon Wizard View Post
    You have to redefine the control or template which defines the script within your extension, and include the updated script file under a "scripts" subdirectory in the extension.

    Code:
      <windowclass name="charsheet_skills" merge="join">
        <sheetdata>
          <windowlist name="skilllist">
            <script file="scripts/charsheet_skilllist.lua" />
          </windowlist>
        </sheetdata>
      </windowclass>
    Regards,
    JPG
    With respect to the MyQuest extension that ships with the BRP ruleset that I'm trying to edit, there are two editable files: the "MyScript.lua" script file and "extension.xml" file. Where exactly would the code block you post go then? Under the window classes heading?

    The code of the extension.xml file is as such:
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!-- Copyright SmiteWorks USA, LLC., 2010  -->
    <root version="2.0">
      <properties>
        <name>Magic World Campaign Extension</name>
    
        <author>SmiteWorks USA, LLC., 2010</author>
        <description>Sample campaign extension for the Basic Roleplaying ruleset.</description>
    
        <exclusiongroup>BRPGameline</exclusiongroup>
    
        <ruleset>
          <name>Basic Roleplaying</name>
        </ruleset>
      </properties>
    
      <base>
    
        <!-- icons -->
        <icon name="cs_logo" file="Custom.png" />
    
        <!-- frames -->
        <framedef name="myq_sheet">
          <bitmap file="myq_sheet.png" />
          <topleft rect="0,0,12,12" />
          <top rect="12,0,322,12" />
          <topright rect="334,0,12,12" />
          <left rect="0,12,12,325" />
          <middle rect="12,12,322,325" />
          <right rect="334,12,12,325" />
          <bottomleft rect="0,337,12,12" />
          <bottom rect="12,337,322,12" />
          <bottomright rect="334,337,12,12" />
        </framedef>
    
        <!-- window classes -->
    
        <!-- tabcontrol template -->
    
        <!-- charsheet templates -->
    
        <!-- script file -->
        <script name="MyQScript" file="scripts/myqscript.lua" />
    
      </base>
    </root>
    FWIW, BRP is not built off of CoreRPG, so I'm not sure if that changes anything.

    Thanks for your help.

  5. #5
    Yes, you could place the windowclass modification in that part of the extension, and you would need to add the modified charsheet_skilllist.lua to the scripts directory in the extension as well.

    Regards,
    JPG

  6. #6
    Excellent. I'll try to test this out when I get home. Thanks for your help. @Moon Wizard

    EDIT:
    It finally calculates the characteristic bonus correctly, so thank you. It does throw a script error and a script warning in the console. I'm not sure if they are fatal errors or not so I figure I'll post them here:
    Code:
    Script Error: [string "scripts/charsheet_skilllist.lua"]:306: attempt to call global 'getWindows' (a nil value)
    The Code block in question at line 306 looks like such (the offending line bolded and underlined)
    Code:
    function checkdefaultskills()
      -- create default skills
      local skilldata = LineManager.getLine().Skills;
      local winlist = {};
      
      for k, w in pairs(getWindows()) do
        if w.getClass()=="charsheet_skill" then
          local label = w.label.getValue(); 
          local type = w.skilltype.getValue();
          if type >= SkillType.NoCheck then
            type = type - SkillType.NoCheck;
          end
          if type~= SkillType.Custom then
            w.skilltype.setValue(SkillType.Ignore);
          end
          if skilldata[label] then
            if winlist[label] then
              table.insert(winlist[label], w);
            else
              winlist[label] = { w };
            end
          end
        end
      end
    and the warning when you click on a character sheet's skill tab this warning pops up
    Code:
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    Script Warning: setValue: Recursive control event or call terminated (numbercontrol:bonus)
    If these aren't show-stopper errors I should worry about then I'll just leave well enough alone. Is this happening because there is a ruleset version of charsheet_skilllist.lua as well as an extension version of the same script with the same name?
    Last edited by FlightlessScotsman; April 23rd, 2017 at 05:34.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Newcastle, UK (for a bit)
    Posts
    24,536
    Don't ignore errors as your script stops running at the point it encounters an error. Work out why getWindows is not valid on line 306 of scripts/charsheet_skilllist.lua
    FG Con 16 Fantasy Grounds Online RPG Convention - Friday April 24th to Sunday April 26th, 2020
    Register at www.fg-con.com for all the latest info.

    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!

  8. #8
    Update:

    For whatever reason I decided to delete everything but the following function in "charsheet_skilllist.lua" and save it in a new script called "charsheet_skilllist_mod.lua"
    Code:
    function getCategoryBonus(influence,characteristic)
      if influence=="Primary" then
        return math.ceil(characteristic/2);
      end
      return 0;
    end
    I edited the extension.xml file to only load the modified script and the MyScript.lua file and lo and behold no more errors and everything works as it should! So Hurray! No more worries, but it really makes me wonder why the same function inside the MyScript.lua just doesn't override the default calculation method as it seems it should.

    Very weird, but hopefully this helps somebody and my pain is somebody else's gain

    A huge thanks again Moon Wizard. Your help was invaluable.

  9. #9
    Quote Originally Posted by Trenloe View Post
    Don't ignore errors as your script stops running at the point it encounters an error. Work out why getWindows is not valid on line 306 of scripts/charsheet_skilllist.lua
    It's a direct copy of the script from "charsheet_skilllist.lua" file inside the BRP ruleset .pak file, so it's nothing I wrote.

    As I said at the top of the thread, I'm no programmer. I've dabbled a bit in javascript and python at points, but It's mostly just me knowing enough to be dangerous, I wouldn't even begin to know how debug and pull apart that error.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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

Log in

Log in