Refer a Friend
Page 127 of 331 First ... 27 77 117 125 126 127 128 129 137 177 227 ... Last
  1. #1261
    Working with rolld, I've been able to get it to roll the extra type die and keep the top two. Gotta figure out how to add in a modifier now.

  2. #1262
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    24,754
    Blog Entries
    1
    Quote Originally Posted by DMReckless View Post
    Working with rolld, I've been able to get it to roll the extra type die and keep the top two. Gotta figure out how to add in a modifier now.
    Very good.
    Have a search in the \scripts folder for nMod and see how to call it, save it and clear it.

  3. #1263
    Darned frustrating, trying to find nMod strings among all that other stuff, hours later, going to bed with no luck.

    ---
    --- Initialization
    ---
    local sCmd = "factwelve";

    -- MoreCore v0.60
    function onInit()
    CustomDiceManager.add_roll_type(sCmd, performAction, onLanded, true, "all");
    end


    function onInit()
    Comm.registerSlashHandler("factwelve", processRoll);
    GameSystem.actions["factwelve"] = { bUseModStack = true };
    ActionsManager.registerModHandler("factwelve", onMod)
    ActionsManager.registerResultHandler("factwelve", onRoll);

    -- send launch message
    local msg = {sender = "", font = "emotefont"};
    msg.text = "Factor12 Dice loaded. Type \"/factwelve ?\" for usage.";
    ChatManager.registerLaunchMessage(msg);
    end

    ---
    --- This is the function that is called when the factwelve slash command is called.
    --- The default value for sParams is equal to "2d12+1d4+0 1"
    ---
    function processRoll(sCommand, sParams)
    if not sParams or sParams == "" then
    sParams = "2d12+1d4+0 1";
    end

    if sParams == "?" or string.lower(sParams) == "help" then
    createHelpMessage();
    else
    local rRoll = createRoll(sParams);
    ActionsManager.roll(nil, nil, rRoll);
    end
    end

    ---
    --- This function creates the roll object based on the parameters sent in
    ---
    function createRoll(sParams)
    local rRoll = {};
    rRoll.sType = "factwelve";
    rRoll.nMod = 0;
    rRoll.sUser = User.getUsername();
    rRoll.aDice = {};
    rRoll.aDropped = {};

    -- If no number to drop is specified, we will assume it is 1
    if(not sParams:match("(%d+)d([%dF]*)+(%d+)d([%dF]*)+(%d+)%s(%d+)") and sParams:match("(%d+)d([%dF]+(%d+)d([%dF]*)+(%d+)+)")) then
    sParams = sParams .. " 1"
    end

    -- Now we check that we have a properly formatted parameter, or we set the sDesc for the roll with a message.
    if not sParams:match("(%d+)d([%dF]*)+(%d+)d([%dF]*)+(%d+)%s(%d+)") then
    rRoll.sDesc = "Parameters not in correct format. Should be in the format of \"2d12+#d#+# #\"";
    return rRoll;
    end

    local sNum, sSize, tNum, tSize, aMod, sDrop = sParams:match("(%d+)d([%dF]+)+(%d+)d([%dF]*)+(%d+)%s(%d+)");
    local count = tonumber(sNum);
    local comp = tonumber(tNum);
    local drop = tonumber(sDrop);

    if (drop > count + comp) then
    rRoll.sDesc = "You cannot drop more results than the number of dice being rolled.";
    return rRoll;
    end

    while count > 0 do
    table.insert(rRoll.aDice, "d" .. sSize);

    -- For d100 rolls, we also need to add a d10 dice for the ones place
    if sSize == "100" then
    table.insert(rRoll.aDice, "d10");
    end
    count = count - 1;
    end

    while comp > 0 do
    table.insert(rRoll.aDice, "d" .. tSize);

    -- For d100 rolls, we also need to add a d10 dice for the ones place
    if sSize == "100" then
    table.insert(rRoll.aDice, "d10");
    end
    comp = comp - 1;
    end

    rRoll.nDrop = drop;

    return rRoll;
    end

    ---
    --- This function first sorts the dice rolls in ascending order, then it splits
    --- the dice results into kept and dropped dice, and stores them as rRoll.aDice
    --- and rRoll.aDropped.
    ---
    function dropDiceResults(rRoll)
    if #(rRoll.aDice) < 2 then return rRoll end
    local len = #(rRoll.aDice) or 0;
    local drop = tonumber(rRoll.nDrop) or 0;
    local dropped = {};
    local kept = {};

    table.sort(rRoll.aDice, function(a,b) return a.result < b.result end);
    local count = 1;
    while count <= len do
    if count <= drop then
    table.insert(dropped, rRoll.aDice[count]);
    else
    table.insert(kept, rRoll.aDice[count]);
    end

    count = count + 1;
    end
    rRoll.aDice = kept;
    rRoll.aDropped = dropped;
    return rRoll;
    end

    ---
    --- This function creates a chat message that displays the results.
    ---
    function createChatMessage(rSource, rRoll)
    local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
    if #(rRoll.aDice) > 0 then
    rMessage.text = rMessage.text .. "[KEPT]";
    for _,v in ipairs(rRoll.aDice) do
    rMessage.text = rMessage.text .. " " .. v.result;
    end
    end
    if #(rRoll.aDice) > 0 and #(rRoll.aDropped) > 0 then
    rMessage.text = rMessage.text .. "\n";
    end
    if #(rRoll.aDropped) > 0 then
    rMessage.text = rMessage.text .. "[DROPPED]";
    for _,v in ipairs(rRoll.aDropped) do
    rMessage.text = rMessage.text .. " " .. v.result;
    end
    end

    return rMessage;
    end

    ---
    --- This function creates the help text message for output.
    ---
    function createHelpMessage()
    local rMessage = ChatManager.createBaseMessage(nil, nil);
    rMessage.text = rMessage.text .. "The \"/factwelve\" command is used to roll a set of dice, removing a number of the lowest results.\n";
    rMessage.text = rMessage.text .. "You can specify the number of dice to roll, the type of dice, and the number of results to be dropped ";
    rMessage.text = rMessage.text .. "by supplying the \"/factwelve\" command with parameters in the format of \"#d#+#d#+# #\".";
    rMessage.text = rMessage.text .. "If no parameters are supplied, the default parameters of \"2d12+1d4+0 1\" are used.";
    Comm.deliverChatMessage(rMessage);
    end

    ---
    --- This is the callback that gets triggered after the roll is completed.
    ---
    function onRoll(rSource, rTarget, rRoll)
    rRoll = dropDiceResults(rRoll);
    rMessage = createChatMessage(rSource, rRoll);
    rMessage.type = "dice";
    Comm.deliverChatMessage(rMessage);
    end

  4. #1264

  5. #1265
    /factwelve 2d12+1d4+1 1
    /factwelve 2d12+1d8+4 1
    Really, anything in that setup works (except for the mod) like
    /factwelve 3d6+2d8+1 2
    will drop the lowest 2 dice but won't add in the 1 mod.

    I'm also having a problem getting it to work as a macro inside the MoreCore character sheet, but that's probably a function of having to set up "factwelve" withe the sheet scripts?
    Last edited by DMReckless; December 5th, 2018 at 14:41.

  6. #1266

  7. #1267
    thanks. followed that, but getting script error:

    Script Error: [string "common/scripts/morecore_rolls/lua"]:80: attempt to concatenate 'sParams' (a nil value}

  8. #1268
    Hi !
    First thanks for this great "rule pak";
    We use it to play hackmaster and it work ok.

    However since last update as a GM i have encounter a little problem: I can't open the Old character selection screen ?
    Now, instead i've got a scrolling list who looks exactly like the NPC list. (no portrait of the character only their name).
    I can open Character sheet from this list but I cannot "own" them, export or import them. Only the create and erase option are available when right clicking in this list.
    For Player who join a game the "old" character selction screen open once at the beginning and if they close it we didn't find a way to open it again.
    I guess there is a new function that i'm not aware of.

    Thanks for the pak anyway it's great !

  9. #1269

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,682
    Quote Originally Posted by Yapadekoi View Post
    However since last update as a GM i have encounter a little problem: I can't open the Old character selection screen ?
    Now, instead i've got a scrolling list who looks exactly like the NPC list. (no portrait of the character only their name).
    Are you on the test channel instead of live?

  10. #1270
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    24,754
    Blog Entries
    1
    Yep - this is an issue on Test - it is fixed in my current build but it wont be ready for release until closer to the 18th.
    PM me if you need it.

Page 127 of 331 First ... 27 77 117 125 126 127 128 129 137 177 227 ... Last

Thread Information

Users Browsing this Thread

There are currently 4 users browsing this thread. (0 members and 4 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