DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1

    Can I get a dice total after/during throwing dice?

    I'm trying to 'keep' a total for a dice roll? I'm trying to roll 3d6, and then pass the value back to the function that it was called into so it outputs to chat AND i keep the total of the roll to then go look up a table.

    So far when I've tried to access the ActionsManager.total, it keeps telling me the die roll that I just rolled is 'attempt to index local 'rRoll' (a nil Value) in the CoreRPG manager_actions.lua

    This is what is causing some of the issue (this is my function roll3d6(tableRolledOn))
    Code:
    local ntotal
    	local number = 3;
    	local type = "d6";
    	--rThrow.description = tableRolledOn;
    	local dice = {};
    	for i = 1, number, 1 do
    		table.insert(dice, type);
    	end
    --	logdebug.chat(dice);
    	-- ntotal = ActionsManager.total(dice);
    	return Comm.throwDice("dice", dice, 0 , tableRolledOn);
    --	print(ntotal);
    These are the lines that I think are giving it trouble. I've tried in the above code to also pass the dice to the total function but that gives me a similar (nil).
    Code:
     diceRoll = DieRolls.roll3d6("some table");
    			 print(ActionsManager.total(diceRoll));
    I've also gotten bad argument to ipairs (table expected, got nil) when trying to pass the dice values.

    (I'm a pretty rank amateur and I'm still trying to figure things out)
    Anybody want a peanut!

  2. #2
    I'm not sure if this might be the problem, but do I need a special actionmanagerhandler or something? Those are the (next) thing that confuse me about when/how to use them.
    Anybody want a peanut!

  3. #3
    If you're just looking for a random evaluation of a dice string, you can use "local nTotal = DiceManager.evalDiceMathExpression("3d6");"

    If you want to actually have the 3D dice rolling involved, you need to have a custom roll handler, so that you can trigger the roll, then when it completes, you can get the result via a registered result callback. (See multiple examples for attack/damage/save/init and more in 5E and 3.5E rulesets; init is probably the simplest).

    Regards,
    JPG

  4. #4

  5. #5
    Thanks Moon and damned.

    The first solution is simple and would work well enough, except for the no-rolling of dice with is kinda nice BUT, it seems like the getting a total of a roll you've made seems really really complicated to me. What I might do until I figure out how to roll 3d6 in the chat, and then use THAT total to roll on a table (critical success/fail/spell fail etc).

    (edit on actual processing)

    I used the little test extension as a base and voila, I can pass back the total AND roll dice!

    now to figure out how to do the plethora of critical tables ...
    Anybody want a peanut!

  6. #6
    Belay that, I was looking at the wrong print; I can get the total with onRoll, but now I have to figure out how to pass that back to the original call....
    Anybody want a peanut!

  7. #7
    Quote Originally Posted by Fezzik Buttercup View Post
    Belay that, I was looking at the wrong print; I can get the total with onRoll, but now I have to figure out how to pass that back to the original call....
    Trying to create a cycle in the code is probably gonna end up as more hassle than its worth. I'd suggest instead attaching any additional data that you would need for processing to the roll itself, and just doing that work downstream in its own function.
    My Forge creations: https://forge.fantasygrounds.com/crafter/9/view-profile
    My GitHub: https://github.com/MeAndUnique
    Buy me a coffee: https://ko-fi.com/meandunique
    Discord: MeAndUnique#6805

  8. #8
    I've gone with just 'rolling' with an arithmetic little function and then going to the appropriate table; it does mean that the critical hit/fail message pops up BEFORE the combat roll and I don't get another fancy dice roll, but it's WAY simpler. Hopefully maybe I can figure out how to roll dice and snatching what I need for it to look at the right table etc, but my mind just can't seem to get the flow of it.

    Damned has been very patient with me That link he shared was actually helpful to me for some things, but so far I haven't been able to completely figure out how to make it work for me.

    Old Man Voice - Basic and Java was so much easier way back in the day (GET OFF MY LAWN!)
    Anybody want a peanut!

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,676
    Quote Originally Posted by Fezzik Buttercup View Post
    I've gone with just 'rolling' with an arithmetic little function and then going to the appropriate table; it does mean that the critical hit/fail message pops up BEFORE the combat roll and I don't get another fancy dice roll, but it's WAY simpler. Hopefully maybe I can figure out how to roll dice and snatching what I need for it to look at the right table etc, but my mind just can't seem to get the flow of it.
    The big thing is that rolling dice is asynchronous - the code that starts the roll ends and then new code runs when the dice roll ends. So it's a lot more complex than just generating a random number within code and immediately continuing that code with the result of the random number.
    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!

  10. #10
    I'll revisit how I might want to roll the dice once I get everything else done and see how to squish it in. I think I understand some of the Initiative in 3.5E; I'll look at the combat too in GURPS and see if I can make sense of that and then go from there. You're walk-through is good, I'm just dense
    Anybody want a peanut!

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
  •  
Fantasy Grounds Merchandise

Log in

Log in