• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Generating Random Attributes and making them stick

dwobbit

Member
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?
 
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.
 
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>

Any ideas?
 
Last edited:
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.php5?title=Language_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.
 
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).
 
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
To look at the results of the debugs, in the Develop menu, first make sure "Enable Data File Debugging" is turned on, then near the bottom, find floating info windows...show debug output.
 
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:
 

Attachments

  • 2023-03-27_21-19-47.jpg
    2023-03-27_21-19-47.jpg
    32.9 KB · Views: 2
Last edited:
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.
 
Back
Top