Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Generating Random Attributes and making them stick (http://forums.wolflair.com/showthread.php?t=67718)

dwobbit March 27th, 2023 12:02 PM

Generating Random Attributes and making them stick
 
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?

Mathias March 27th, 2023 01:28 PM

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.

dwobbit March 27th, 2023 02:11 PM

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?

Mathias March 27th, 2023 02:39 PM

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.

dwobbit March 27th, 2023 03:32 PM

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).

Mathias March 27th, 2023 04:17 PM

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.

dwobbit March 27th, 2023 04:34 PM

1 Attachment(s)
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:

Mathias March 28th, 2023 07:52 AM

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.

dwobbit March 28th, 2023 02:54 PM

Thank you! This has been super helpful and I now have this portion working!


All times are GMT -8. The time now is 04:53 AM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.