FG Spreadshirt Swag
  1. #1

    Table Roll Modifiers within the Code

    Hi All, I would like to know if it is possible to add modifiers in the LUA code when rolling on a Table. The attached table is a good example where 2d6 are rolled and it could have a 0, +1 or +2 modifier depending on the targets motive type. I know I can use the modifier box in the main desktop to add this number but can it be done within the code to automate the process. The current section of code that calls the table to be rolled on is:

    TableManager.processTableRoll("", "Vehicle Motive Systems Damage");

    I have started to look at the Manager_table.lua code (from CoreRPG Ruleset copied into my own extension) but cannot see what could be done, if anything.

    Any help would be greatly appreciated.
    Attached Images Attached Images

  2. #2
    Sure, but it would need to be coded and made into an extension. In this case after the table is rolled, you would have to parse out the text and then send it to the modifier box. This is a simplified description of the process, but that is how I would do it.
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Idea Informer

  3. #3
    Quote Originally Posted by superteddy57 View Post
    Sure, but it would need to be coded and made into an extension. In this case after the table is rolled, you would have to parse out the text and then send it to the modifier box. This is a simplified description of the process, but that is how I would do it.
    Thanks. I will see what I can do but may well come back for some more advice.

  4. #4
    It seems you modification I needed was fairly straightforward.

    I have copied the manager_table.lua file from the CoreRPG ruleset and renamed it to manager_table2.lua. Then it was a case of modifying the processTableRoll function to add a third parameter - nRollMod. See below for the changes (highlighted in Bold):

    function processTableRoll(sCommand, sParams, nRollMod)
    -- nRollMod used to allow external modifier to be used from within certain attack/damage rolls


    local aTableName = {};
    local aColumnName = {};
    local aDiceString = {};
    local bHide = false;
    local bError = false;

    local aWords = StringManager.parseWords(sParams, "%(%)%[%]:");
    local sFlag = "";
    for k = 1, #aWords do
    if aWords[k] == "-c" or aWords[k] == "-d" then
    sFlag = aWords[k];
    elseif aWords[k] == "-hide" then
    sFlag = aWords[k];
    bHide = true;
    elseif aWords[k]:sub(1,1) == "-" then
    bError = true;
    break;
    else
    if sFlag == "" then
    table.insert(aTableName, aWords[k]);
    elseif sFlag == "-c" then
    table.insert(aColumnName, aWords[k]);
    elseif sFlag == "-d" then
    table.insert(aDiceString, aWords[k]);
    elseif sFlag == "-hide" then
    bError = true;
    break;
    end
    end
    end

    local sTable = table.concat(aTableName, " ");
    if bError or not sTable or sTable == "" then
    ChatManager.SystemMessage("Usage: /rollon tablename -c [column name] [-d dice] [-hide]");
    return;
    end
    local nodeTable = findTable(sTable);
    if not nodeTable then
    ChatManager.SystemMessage(Interface.getString("tab le_error_lookupfail") .. " (" .. sTable .. ")");
    return;
    end

    local rTableRoll = {};
    rTableRoll.nodeTable = nodeTable;
    if bHide then
    rTableRoll.bSecret = true;
    end
    rTableRoll.nColumn = findColumn(nodeTable, table.concat(aColumnName, " "));
    if #aDiceString > 0 then
    local sDice = table.concat(aDiceString, "");
    rTableRoll.aDice, rTableRoll.nMod = StringManager.convertStringToDice(sDice);
    else
    rTableRoll.aDice, rTableRoll.nMod = getTableDice(nodeTable);
    end

    -- Addition of nRollMod. Roll code driven modifier.
    rTableRoll.nMod = rTableRoll.nMod + nRollMod;

    performRoll(nil, nil, rTableRoll, false);
    end


    So if you need to parse a modifier to a table when it is rolled you would now use the following command:

    TableManager2.processTableRoll("", "Table Name", Modifier);

    Where TableName is the name of the table you are calling and Modifier is the number applied to the roll within the table. This can either be a variable defined in your code or a fixed value.

    Here are a couple of examples I use:

    -- Vehicle Motive System Critical
    if sMotiveType ~= nil then
    if sMotiveType == "v" then
    nMotiveMod = 2;
    elseif sMotiveType == "h" or sMotiveType == "w" then
    nMotiveMod = 1;
    else
    nMotiveMod = 0;
    end

    TableManager2.processTableRoll("", "Vehicle Motive Systems Damage", nMotiveMod);
    end

    -- Structure Critical hit check
    -- Debug.chat("Structure = ",ArmourTxValue);
    if ArmourTxValue > 0 then
    TableManager2.processTableRoll("", "Mech Attack Critical", 0);
    end


    The second use of TableManager2 could actually use the Core TableManager call as the modifier is set to 0.

    If you find any issue with this then let me know.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Log in

Log in