I just discovered Perchance this morning while looking for some options to consolidate and “oracle-ize” some pen-an-paper game tables from Ganesha games. I’m a retired and somewhat lazy software developer who figured there should be a way to accomplish this without reinventing the wheel, and Perchance seems to fit the bill well. One initial question - the example generator html files seem to have a single call to “update” when the button is clicked. Can a generator respond to multiple button messages? For example if I wanted to include two unrelated tables in a single generator file ? I have about 15 tables for one game, and would like to be able to have buttons for each table, plus a read-only scrolling text area that contains the output from each click, like a journal.

  • @perchanceM
    link
    English
    33 months ago

    Yep, if you have <div id="abc">[animal]</div> and you have <button onclick="update(abc)">randomize</button> then it’ll only update that particular HTML element with id="abc". Examples:

    BTW, there are quite a few examples on perchance.org/examples and Google has indexed them - e.g. I found these quickly by searching “multiple buttons perchance example” and “perchance history example”. It can sometimes be hard to phrase Google searches when you’re new to a subject, so should feel very welcome to ask questions like this here - just a heads up in case it’s helpful next time you run into an issue like this.

    • @cwiggins999OP
      link
      English
      23 months ago

      Excellent - thanks! Each environment seems to have nuances, but I should have tried this google approach - glad to see it is well indexed. The history examples are perfect.

      I looked at the DYI API also - can it handle a parameter for choosing a particular output, as in the multiple-independent-outputs-example? Like the individual buttons do, using “update(out1)”, “update(out2)”, etc.? I’m thinking of invoking this in Tabletop Simulator’s ingame tablet, and it has an earlier version of chromium that doesn’t look like it supports the generator URLs directly, so might use an API versus trying to transpile.

  • @wthit56
    link
    English
    33 months ago

    You can also just not use the update at all. (People can still call it on the other side, but you don’t need to use that as the mechanism by which you change stuff.) You can just use regular JS and set it up to work however you want it to work.