Starfinder Playlist
Page 1 of 3 123 Last
  1. #1

    Roll based on numberfield

    Problem mostly solved. onto next steps:

    1: get the name of the roll from dragdata to display in chat upon completion
    2: get a "push" mechanic (add a level of stress, roll all dice again minus any 6's)

    arpgcharmain.png
    arpgcharabilities.png
    arpgcharinventory.png
    arpgcharnotes.png
    Code:
    <!--Stress Points-->
    			<boxframe>
    				<bounds>260,45,230,80</bounds>
    			</boxframe>
    			<emptyframe name="stressback">
    				<bounds>270,55,210,60</bounds>
    			</emptyframe>
    			<label name="stressLabel">
    				<anchored to="stressback" position="insidetopleft" offset="20,10" />
    				<static text="Stress Level" />
    			</label>
    			<buttongroup_counter name="StressPoints">
    				<anchored to="stressback" position="insidetopleft" offset="20,25" />
    				<sourcefields>
    					<current>hp.stress</current>
    				</sourcefields>
    				<values>
    					<maximum>10</maximum>
    					
    				</values>
    			</buttongroup_counter>
    			<basicnumber name="stressroll" source="stressroll.slot.amount">
    				<min>0</min>
    				<max>10</max>
    				<anchored to="stressLabel" position="right" offset="60,0" width="30" height="20" />
    				<script>
    					function onDoubleClick(x, y)
    						Comm.throwDice( "dice", {"dS"}, getValue(), description)
    					end
    					
    					function onDragStart(button, x, y, dragdata)
    						dragdata.setType("dice");
    						dragdata.setDieList({ "dS" });
    						dragdata.setNumberData(getValue());
    						dragdata.setDescription("sSkillRollDesc");
    
    						return true;
    					end
    				</script>
    			</basicnumber>
    Attached Files Attached Files
    Last edited by pr6i6e6st; August 14th, 2019 at 01:41.

  2. #2
    Like, i really don’t seem to grasp how scripting works, what’s a template and what’s native.

    I basically just want

    Function onDragStart()
    nDice = stressroll.slot.amount.getValue()
    tDie = getDice(“ dS ”)

    For nDice do
    dragdata.setDice((nDice*{tDie}))
    End

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Do a search (find in files) in various FG rulesets - search for "table.insert(aDice" in the 5E ruleset, for example, and there's an example where a number of dice are added to the aDice table:

    Code:
    		for i = 1, nHDMult do
    			table.insert(aDice, "d" .. nHDSides);
    		end
    You can't just add multiple dice to the aDice table in one command (i.e. doing multipliers like dice*number) , you need to use a for loop to add each dice at a time. So, maybe try something like this:

    Code:
    		for i = 1, nDice do
    			table.insert(aDice, "dS");
    		end
    But also keep in mind what I said here: https://www.fantasygrounds.com/forum...l=1#post445975
    Last edited by Trenloe; August 8th, 2019 at 21:34.
    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!

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Actually, a better search to get lots of examples is to search (find in files) for "table.insert(rRoll.aDice" in the 3.5E ruleset.
    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!

  5. #5

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,922
    Actually, I believe you can.

    Code:
    aDice = { "d6", "dS", "d20" };

  6. #6
    Quote Originally Posted by Andraax View Post
    Actually, I believe you can.

    Code:
    aDice = { "d6", "dS", "d20" };
    That does work, but with static number of dice, where I need it to be a variable based on the number field you drag the dice from. Unless I’m missing something.

    I’ll have to look later to see what I can find for the “for” function and determine if I know what the variable is for the number field. (In the instance I provided, I am to believe it’s “stressroll.slot.amount” as that works with the button_counter for the <sourcefield><current>

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Quote Originally Posted by pr6i6e6st View Post
    That does work, but with static number of dice, where I need it to be a variable based on the number field you drag the dice from.
    See the second code block in post #3 above.
    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
    Here's an example out of the WOiN ruleset.

    Very basically 'What's Old is New' builds a Dice Pool, you add your Stat + Skill + Modifier Dice and on top you can add Luck dice etc.

    Here's the code, it reads from the 'Attack' field which is on the screen listed next to an attack (say a Pistol), then checks for Modifiers and then inserts the extra dice or removes them, as the Desktop +1, +2, -1, -2 are actual D6 to remove.

    Hope this helps.

    Code:
            local nTotal = attack.getValue().."d6";
    	local aDice, nMod = StringManager.convertStringToDice(nTotal);
    	
    	-- add Modifier dice
    	local bDescNotEmpty = true;
    	local sStackDesc, nStackMod = ModifierStack.getStack(bDescNotEmpty);
    		
    	local modifierDice = nStackMod;
    
    	if modifierDice > 0 then
                for i=1,modifierDice do
                    table.insert(aDice, "d6");
                end
    	else
    	    for i=1,-modifierDice do
                    table.remove(aDice);
                end
            end
    Cheers,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  9. #9
    Quote Originally Posted by MadBeardMan View Post
    Here's an example out of the WOiN ruleset.

    Very basically 'What's Old is New' builds a Dice Pool, you add your Stat + Skill + Modifier Dice and on top you can add Luck dice etc.

    Here's the code, it reads from the 'Attack' field which is on the screen listed next to an attack (say a Pistol), then checks for Modifiers and then inserts the extra dice or removes them, as the Desktop +1, +2, -1, -2 are actual D6 to remove.

    Hope this helps.

    Code:
            local nTotal = attack.getValue().."d6";
    	local aDice, nMod = StringManager.convertStringToDice(nTotal);
    	
    	-- add Modifier dice
    	local bDescNotEmpty = true;
    	local sStackDesc, nStackMod = ModifierStack.getStack(bDescNotEmpty);
    		
    	local modifierDice = nStackMod;
    
    	if modifierDice > 0 then
                for i=1,modifierDice do
                    table.insert(aDice, "d6");
                end
    	else
    	    for i=1,-modifierDice do
                    table.remove(aDice);
                end
            end
    Cheers,
    MBM
    I’ll have to give this a look, do I need to add any script.lua’s? Or are these available in CoreRPG?
    Quote Originally Posted by Trenloe View Post
    See the second code block in post #3 above.
    Yes, sorry, I meant to say I’ll need to check out what you’ve suggested.

  10. #10
    Yes you will need to add it to the script wherever you 'build' your dice pool.
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

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
  •  
FG Spreadshirt Swag

Log in

Log in