If/then, cases, or conditions

  1. 3 years ago

    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.

    e.g.
    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) {
    $("#obj323").trigger(PubCoder.Events.Run);
    } else if (showFloorObjectsNumber === 1) {
    $("#obj326").trigger(PubCoder.Events.Run);
    } else if (showFloorObjectsNumber === 2) {
    $("#obj329").trigger(PubCoder.Events.Run);
    } else if (showFloorObjectsNumber === 3) {
    $("#obj332").trigger(PubCoder.Events.Run);
    }

    I hope this helps!

    Greetings,
    Casimir

  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

    Cheers,
    Casimir

  9. Casimir,

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

    Phil

  10. Hey Phil,

    I will definitely do that!

    Cheers,
    Casimir

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

 

or Sign Up to reply!