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

Links:

  • 15 Posts
  • 12 Comments
Joined 1 year 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>