If/then, cases, or conditions

  1. last year

    Thinking this would be a great addition to PubCoder, it I was able to setup a condition so that I could evaluate a property based on an interaction.

    If (audio 1 is playing) then (stop audio),
    else (play audio)

    if (condition) then (outcome)

    I am guessing right now though I'd have to use JS to accomplish this? any ideas how?
    Thanks in advance.

  2. I too think this would be a great addition to Pubcoder.
    Also - how about collision detection?

  3. Yes, these would be awesome.

  4. Angelo S

    22 Dec 2020 Administrator

    Yes guys you have to use javascript to accomplish if/then. You can put your script in a Run JavaScript action, for example, then run action lists from there from the various if/then/else branches

  5. Hi Angelo,

    an example of how to do this would be great.

  6. Hi guys,

    Here is a sample of some code I use in JavaScript, to show only 3 of a total of 4 objects.
    The trigger(PubCoder.Events.Run) are used on action lists.

    var showFloorObjectsNumber = Math.floor(Math.random() * 4);
    if (showFloorObjectsNumber === 0) {
    } else if (showFloorObjectsNumber === 1) {
    } else if (showFloorObjectsNumber === 2) {
    } else if (showFloorObjectsNumber === 3) {

    I hope this helps!


  7. Thanks for that Casimir.

    What I'd really like would be an Udemy type course - "Javascript for Pubcoder".
    That would tie everything up in one place.

  8. Hey Phil,

    In fact, I'm thinking about doing a video tutorial series on PubCoder, but in a few months, after some more experimenting.

    In the meantime, if you're stuck with something, feel free to contact me at casimir.smets@icloud.com


  9. Casimir,

    please let me know when your tutorial is ready and thank you for your kind offer.


  10. Hey Phil,

    I will definitely do that!


  11. indeed. looking forward to it also. :)


or Sign Up to reply!