• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    [ANSWERED] Trying to better understand JavaScript in Izzyv4

    How To... ?
    3
    7
    791
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      skuven Beta Silver last edited by Woland

      Hi all

      I've been working through a simple javascript thing I want to achieve, but no experience of writing code other than html about 20 years ago...

      I have 4 values going into the JS actor, and I want those values to be ordered highest to lowest, then spat out at the other side as 4 outputs - highest at the top, lowest at the bottom.

      Utilising chat GPT I have a stable JS actor that closes and takes 4 random shuffled numbers in, but don't really know what i'm doing, and the values are not coming out. I read both the help in the actor, and the isadora page for help.

      I tend to find I can learn better by dissecting something that is working. Is someone around here able to simply build this script so I can import it and see where I was going wrong?

      It's driving me mad! I would normally achieve the task using isadoras actors, but the method around it gets quite complicated, considering the general simplicity of the outcome. It utilises a lot of comparators, max value, remapping, etc.

      The intended outcome is that we can create with the students a realtime score board with names. I need to understand how complex this is before I set it as a task for them - knowing full well I can't actually do it myself!

      This would give me good insight into simple java script utilisation for when I am teaching interactivity at work.

      Many thanks in advance!

      Steve

      Juriaan DusX 2 Replies Last reply Reply Quote 0
      • Juriaan
        Juriaan Tech Staff @skuven last edited by

        @skuven

        Array Sort - Example in Isadora

        This example allows you to do a quick highest to lowest. You can simple change the inputs and outputs to scale it with more items or less if needed.

        Isadora 3.1.1, Dell XPS 17 9710, Windows 10
        Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
        Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

        S 1 Reply Last reply Reply Quote 5
        • DusX
          DusX Tech Staff @skuven last edited by

          @skuven said:

          good insight into simple java script

           take a look at Juriaans script in the Javascript actor. 

          The two key points are:
          One, how he is creating an array by looping through the input arguments (also an array) and creating arrayToBeSorted by using push() to add each value to the end of the array.JavaScript Array push() Method

          Two, how he is using the very powerful (and slightly confusing to learn) sort() function, to apply a sort to the array. The method for the application of the sort() is defined after the calling of sort() as a simple function that returns a-b. Really to understand that part you need to read up on the function. JavaScript Array sort() Method

          Troikatronix Technical Support

          • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
          • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
          • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

          Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

          Juriaan S 2 Replies Last reply Reply Quote 2
          • Juriaan
            Juriaan Tech Staff @DusX last edited by

            @dusx
            Thanks Dusx for adding that and making sure that we also learn the methods that were being used.

            The only thing that I have to add is that 'arguments' or basically the 'array' that gets fed into our main function is not of type 'array', or it gives an error in your Windows > Show Monitor view when you try to sort the arguments array.

            That is why it was required to make a new array that is basically an mirror of the arguments array, that way we could actually execute the built-in-methods of an array like 'sort'

            Isadora 3.1.1, Dell XPS 17 9710, Windows 10
            Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
            Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

            1 Reply Last reply Reply Quote 1
            • S
              skuven Beta Silver @Juriaan last edited by

              @juriaan

              I'd love to say this makes sense but it doesnt, however, it's very helpful to have the solve. Thankyou.

              maybe I should do a scripting course...

              DusX 1 Reply Last reply Reply Quote 0
              • S
                skuven Beta Silver @DusX last edited by

                @dusx

                Thanks for this, it's gone over my head though. I simply don't know enough about scripting. Thanks for your efforts though!

                1 Reply Last reply Reply Quote 0
                • DusX
                  DusX Tech Staff @skuven last edited by

                  @skuven said:

                  maybe I should do a scripting course

                   If this is something you are considering, you might look at Python rather than Javascript. When working in Isadora, python will open up many more possibilities, and once you learn one it will make the other much easier.

                  Troikatronix Technical Support

                  • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
                  • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
                  • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

                  Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post