So I’m working on an item roller that has two outputs. (The generator linked is just a quick example)

The only problem is: I can’t figure out how to make it so the random boxes can have separate amounts without affecting each other. For example: I put the number “2” in the “Item Drops” section and the number “4” in the Puzzle drop. Both outputs roll 4 items.

This isn’t a big deal as I can roll one and then enter the amount and roll the other, but I would like to know if there’s any way to make it so both amounts work independently.

  • perchance@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    10 months ago

    Ah so you just need to make sure that you’re using two separate variables - e.g. numItems1 and numItems2 instead of using numItems for both. So if you change this:

    oninput="numItems=Number(this.value)"
    

    to this:

    oninput="numItems1=Number(this.value)"
    

    and change this:

    <b>Items:</b> [forms.selectMany(numItems).joinItems(", ") ]
    

    to this:

    <b>Items:</b> [forms.selectMany(numItems1).joinItems(", ") ]
    

    Then that should give you the behavior that you’re looking for. And you can of course change the other numItems to numItems2.

    Here’s a working example based on the generator you linked: https://perchance.org/xnwieplpx0#edit