Thread: Roll based on numberfield
-
August 7th, 2019, 08:08 #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>
Last edited by pr6i6e6st; August 14th, 2019 at 01:41.
-
August 8th, 2019, 20:55 #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
-
August 8th, 2019, 21:14 #3
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
Code:for i = 1, nDice do table.insert(aDice, "dS"); end
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!
-
August 8th, 2019, 21:22 #4
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!
-
August 8th, 2019, 21:27 #5
- Join Date
- Jun 2013
- Location
- Isanti, MN
- Posts
- 2,922
Actually, I believe you can.
Code:aDice = { "d6", "dS", "d20" };
-
August 8th, 2019, 21:40 #6
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>
-
August 8th, 2019, 21:44 #7Private 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!
-
August 8th, 2019, 21:51 #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
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
August 8th, 2019, 21:59 #9
-
August 8th, 2019, 22:02 #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