I make generators on Perchance.org and do a bunch of other cool things.

Links:

  • 51 Posts
  • 159 Comments
Joined 3 months ago
cake
Cake day: March 24th, 2024

help-circle




  • Another great use of evaluateItem (from my experience) is that it helps evaluate strings containing arbitrary code into proper output behind-the-scenes before modifying them with other properties or functions. For example, running ["[conjugate(verb).gerund] [adjective.pluralForm]"] outputs as expected, a phrase consisting of a gerund verb and a pluralized adjective word. The Perchance engine evaluates the unevaluated string right away after any modifications (for example, through titleCase) were made. And so, running ["[conjugate(verb).gerund] [adjective.pluralForm]".titleCase] will result in a mixed undefined or (syntax error) output (e.g. intending undefined) because it converted the unevaluated string (which is the Perchance code) into title case before it was evaluated, and results in an unwanted output.

    But prepending evaluateItem right before any modification would do the opposite - it evaluates the string before any modifications was made. Using that, running ["[conjugate(verb).gerund] [adjective.pluralForm]".evaluateItem.titleCase] would output a properly title cased phrase in that same format because the Perchance code inside the string is evaluated before the final output was eventually made title cased.




  • While the event is starting, I want to mention some more thoughts I’ve been keeping earlier after hosting the event midnight, about some planned updates for the Events page in the future (and probably going to implement them in the next Preview updates right away):

    • Some of the big events (like image contests and big moment updates like “A Venture for the Big Update”) will be integrated into the Hub for greater visibility (so the event will also be shown as a Hub event in the Events tab), but some smaller events (like break times or Silent Days) will only be exclusively shown on the Generator Manager Events page
    • The description will also use Markdown since I feel that wasn’t well-polished enough and would sometimes break out when writing down for the first event
    • Probably also planning for an entire UI overhaul/rearrangement for the event page as well
    • Also planning to implement an events flyout somewhere in the sidebar or the Home page (similar to the Events flyout in the Hub)
    • etc, etc…

    (Will write down more once they start to pour in)




  • You can prevent the output from accidentally evaluating the selectOne of empty n arrays by just not evaluating the <span contenteditable ... part when that empty array has no length (basically you put a condition in which if n isn’t empty then evaluate the span word element, which eliminates that syntax error problem):

    You can also check for n.length > 0 instead of n.length. Also pretty cool generator concept! A random letter generator button might be a good idea. Here’s how would you implement this using a list and a button:

    letter
      ["{A-Z}".selectMany(Math.floor(Math.random()*4)+1)]
    
    <input id="acronymInput" oninput="acronym = this.value" placeholder="type an acronym :)" value="TPK" />
    <button onclick="ltr = letter.evaluateItem, acronymInput.value = ltr, acronym = ltr, count = -1, update()">random letter</button>
    







  • <br>Death Chance: <select oninput="aListName.Death_Chance = this.value">
      <option value="Moral Blow">Moral Blow</option>
      <option value="Tragedy">Tragedy</option>
      <option value="Destruction">Destruction</option>
      <option value="Devastation">Devastation</option>
      <option value="Calamaty">Calamaty</option>
      <option value="Plague">Plague</option>
      <option value="Eradication">Eradiction</option>
      <option value="Extinction">Extinction (WARNING: DON'T) </option>
    </select>
    <p id="out1">[warningList]</p>
    <button onclick="update(out1)">Show</button>
    <br>Illness type: <select oninput="aListName.Illness_type = this.value">
      <option value="Whitecough">Whitecough</option>
      <option value="Carrionplace Disease">Carrionplace Disease</option>
      <option value="Tainted prey">Tainted prey</option>
    </select>
    

    Here is a modified code for the dropdown menus so that they assign the values to the variables properly (since Death_Chance and Illness_type are apparently stored into some sort of parent list, so you can rename aListName to the name of that list). Also, if the dropdown menu doesn’t work, try changing oninput to onchange.

    You’ll also need to associate the variables written in dynamic odd notations in lists to reference the parent list as well (e.g., [Death_Chance == "Moral Blow"] to [aListName.Death_Chance == "Moral Blow"]).


  • Okay, so first you add the quotes between these curly brackets wrapped syntaxes (and remove the quotes around the none part) so they’ll be evaluated properly:

    And then change the rarity picking mechanism (evaluateItem first, create a matchable version, and then display the evaluated version instead of just selectOne and then display) so it’ll be matched properly when picking a gimmick and an ability, to this:

    [ra1 = rarity.evaluateItem, ra = ra1.match(/[A-Z]+/g)[0], ra1]