My goal with this seems simple: if “family” is not a listed value under the random enemy chosen, print “N/A” instead. However, I have zero clue as to how that could be done. I’m looking for a method that would still work well on a larger scale because I plan to apply this fix to this other generator I made: https://perchance.org/pikmin-enemy-generator#edit

  • Yeetus_McGee@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    17 days ago

    Update: I believe I figured it out! This line seems to achieve the effect I’m going for: [w.family = w.family || “N/A”, “”]

    However, touching up the code has led me to a new question… How might I go about keeping the randomize button from jittering while the image loads?

    • Qinerous@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      17 days ago

      To prevent the button from shaking, set a specific height for Output

      <div style="height:80px;">
       <p id="outputName">[w = enemy.selectOne]</p>
      </div>
      

      just add this tags around of your <p id="outputName">[w = enemy.selectOne]</p>