![]() |
Junior Member
Join Date: Jan 2020
Posts: 12
|
I am trying to allow my players to generate random attribute scores when they create their characters, using HL ability to generate random numbers. I have no problem generating the values as the system requires. What I need help with is, How do I get those values to be assigned to the attributes and persist when the portfolio is saved and then reopened???
I know it is possible as the 5e SRD uses something along these lines for Background Personality Traits, Ideal, Bond, and Flaw random picks.... Can someone please help? |
![]() |
![]() |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,169
|
You'd create an action script that rolls the dice and overwrites the user fields on the appropriate attributes and create a trigger button to run the action script. Then, the user will click the button to get the die rolls. Depending on your game, you may have separate buttons for each attribute, or one button that adds to all of them.
|
![]() |
![]() |
Junior Member
Join Date: Jan 2020
Posts: 12
|
This is what I did but the button does not generate any numbers:
Code:
<portal id="Random" style="actBig" tiptext="Click here to randomly generate attributes."> <action action="trigger" buttontext="Roll Stats" confirm="This will generate random values for all attributes. Proceed?"> <trigger><![CDATA[ hero.child[attrStr].field[trtUser].value = random(6) + random(6) + 1 hero.child[attrAgl].field[trtUser].value = random(6) + random(6) + 1 hero.child[attrCon].field[trtUser].value = random(6) + random(6) + 1 hero.child[attrInt].field[trtUser].value = random(6) + random(6) + 1 hero.child[attrEdu].field[trtUser].value = random(6) + random(6) + 1 hero.child[attrChr].field[trtUser].value = random(6) + random(6) + 1 ]]></trigger> </action> </portal> Last edited by dwobbit; March 27th, 2023 at 05:47 PM. |
![]() |
![]() |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,169
|
That looks as though it should work. There's no error messages? When you click the button, what exactly happens? At this point, I need to know exactly what the error is.
Note: random(6) gives 0-5, so 2d6+1 wound be random(6) + random(6) + 3 http://hlkitwiki.wolflair.com/index....age_Intrinsics Oh, and if you switch to advanced mode when writing a reply on this forum, there's a "Code" button you can use to present things better. |
![]() |
![]() |
Junior Member
Join Date: Jan 2020
Posts: 12
|
I get no error message, I just also get no values for the attributes. When I click the button I get the message "This will generate random values for all attributes. Proceed?". When I click the "Yes" button I get nothing.
Understood on the way random works... I am actually shooting for 2d6-1 (which random(6) + random(6) + 1 gives me). |
![]() |
![]() |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,169
|
Hmm. I'm not sure where to look next. Let's add some debugging - test what's going on.
Within the trigger script: Code:
debug "Strength" debug "Minimum: " & hero.child[attrStr].field[trtMinimum].value debug "Maximum: " & hero.child[attrStr].field[trtMaximum].value debug "Initial: " & hero.child[attrStr].field[trtUser].value hero.child[attrStr].field[trtUser].value = random(6) + random(6) + 1 debug "After Adding Random: " & hero.child[attrStr].field[trtUser].value |
![]() |
![]() |
Junior Member
Join Date: Jan 2020
Posts: 12
|
So I figured out this part...Thank you! The portal was outside the attribute pick template.
Now I need to figure out how to get the button to appear once, either above or below the attributes.... OR, is there a way to get it to work from outside the attribute picktemplate??? This is what I currently have: Last edited by dwobbit; March 27th, 2023 at 06:26 PM. |
![]() |
![]() |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,169
|
The trigger portal is expected to be outside the attribute pick template. The way I'd do this is to create a template, which contains the trigger button, and then place that template into the same layout as the attribute table with a templateref and then arrange the two visual elements as you like.
|
![]() |
![]() |
Junior Member
Join Date: Jan 2020
Posts: 12
|
Thank you! This has been super helpful and I now have this portion working!
|
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|