I’m working on my first project using Perchance to create an RPG character generator. I want to add a feature where, if a generated character’s race has subraces, there’s a chance for a subrace to be generated as well.

For example, if the race “Elf” is generated, I want there to be a chance that it specifies “High Elf,” “Wood Elf,” or “Dark Elf” as a subrace. How can I implement this functionality in Perchance?

  • BluePower@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    8 days ago

    My solution is quite simple here. You just create a list of races (in this example, list of fruits) that has a sublist of race types (in this example, fruit types),

    fruit
      Apple
        Green Apple
        Red Apple
        Blue Apple
      Grape
        Red Grape
        Green Grape
      Berries
        Blackberry
        Blueberry
    

    and then reference them in the output like this:

      Fruit: [fr = fruit.selectOne, fr.getName]
      Fruit type: [fr]
    

    You can then change the references of fruits to races and modify them as you like.

    races
      Elf
        High Elf
        Wood Elf
        Dark Elf
      ...
    
    • 🎲VioneT@lemmy.worldM
      link
      fedilink
      English
      arrow-up
      3
      ·
      8 days ago

      With this, you can also specify directly each items’ odds:

      output
        Race: [r = races.selectOne, r.getName] <br> Sub-Race: [r]
        Race: [r = races.evaluateItem] <br> Sub-Race: [races[r]] // Using the Dynamic Sublisting.
      
      races
        Human^1.5
          Eastern Human^0.4
          ...
        Elf^0.2
          High Elf^0.3
          Wood Elf^0.3
          Dark Elf^0.1
        ...
      

      This would mean, you can have the chance of it being a ‘Elf’ or other races, then you can also specify the odds of the subraces.