DICE PACKS BUNDLE
  1. #1

    Scripting - Using < and > operators

    Afternoon Folks,

    Been working on the scripting required for working out the MOD values within Traveller.

    However I've spent that last hour or more (time flies when you're coding) hitting a brick wall.

    Seems;

    Code:
    if nMyValue == 0 then
      nMyModValue = -3;
    elseif nMyValue <=2 then
      nMyModValue = -2;
    elseif nMyValue <=4 then
      nMyModValue = -1;
    end
    Throws an error upon loading the ruleset.

    However I do have it working using a long winded method

    Code:
    function onSourceUpdate()
    						
    local nValue = calculateSources();
    local nModValue = 0;
    						
    if nValue == 0 then
        nModValue = -3;
    elseif nValue == 1 then
        nModValue = -2;
    elseif nValue == 2 then
        nModValue = -2; 
    else
        nModValue = 0;
    end
    However I've got the values 0-15 to check so that's a lot of code for something I should be able to (hopefully) say x < y.

    Cheers
    Colin

  2. #2

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,922
    Is your code in an XML file? If so, you need to replace "<" with "&lt;" and ">" with "&gt;".

  3. #3
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    In Lua, you should be able to use the alternative operators: gt, lt, ge, le. These replace >, <, >= and <=. This avoids conflict with the XML.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  4. #4
    Morning Folks,

    Oddness, I thought I replied to this thread last night.

    Got it working, using the &lt; etc as this is within the character sheet XML main.

    Now I'm going to experiment with it, as I hate having the exact same code copied for each ability so I'll see if I can move it to it's own script file (then comes the fun of passing arguments).

    Cheers though, got it working.

    Colin

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
  •  
5E Character Create Playlist

Log in

Log in