• Isadora
  • Get it
  • Forum
  • Help
  • ADD-ONS
  • Newsletter
  • Impressum
  • Dsgvo
  • Impressum
Forum
    • Categories
    • Recent
    • Popular
    • Tags
    • Register
    • Login

    Javascript actor with trigger input

    How To... ?
    3
    7
    1.6k
    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.
    • T
      tadakan
      last edited by

      I wanted to confirm that there's a way to interact with a javascript actor using a trigger input. If an actor that outputs a trigger is connected to an input, it changes to a trigger input. It's not clear how the code would be configured to listen for that input. Is it a boolean? or?

      Thanks
      Tom

      OSX 10.11.6 on 15" rMBP from Oct. 2014. 2.5ghz i7 16gb ram.

      1 Reply Last reply Reply Quote 0
      • T
        tadakan
        last edited by

        For example, I would like to randomly generate a value from a range other than 0-100. Using the random actor seems to generate a number heavily weighted towards whatever the max value selected is (i.e. it's generating 0-100 and rounding down to the max value.) I need it to generate a new value every time it is triggered by something.

        so I wrote this code:

        function main()

        {

        var min = arguments[0];

        var max = arguments[1];

        var trig = arguments[2];

        if (trig !== null) {

        function getRandomInt(min, max) {

        return Math.floor(Math.random() * (max - min + 1)) + min;

        }

        }

        }

        OSX 10.11.6 on 15" rMBP from Oct. 2014. 2.5ghz i7 16gb ram.

        1 Reply Last reply Reply Quote 0
        • T
          tadakan
          last edited by

          And... the answer is yes. It does work, I just suck at troubleshooting code.

          here's the updated:

          function main()

          {

          var min = arguments[0];

          var max = arguments[1];

          var trig = arguments[2];

          if (trig !== null) {

          return Math.floor(Math.random() * (max - min + 1)) + min;

          }

          }

          OSX 10.11.6 on 15" rMBP from Oct. 2014. 2.5ghz i7 16gb ram.

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

            I am glad you worked it out...
            How triggers are handled could be better covered in the tutorials.. I will look at making some updates.

            Troikatronix Technical Support

            • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
            • Isadora Add-ons: https://troikatronix.com/add-ons/
            • My Add-ons: https://troikatronix.com/add-ons/?u=dusx

            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 0
            • T
              tadakan
              last edited by

              Speaking of how stuff is handled... I was trying to figure out today if it was possible to use javascript to determine the size (height and width in px) of an image file? The actor accepts image files as input...

              OSX 10.11.6 on 15" rMBP from Oct. 2014. 2.5ghz i7 16gb ram.

              1 Reply Last reply Reply Quote 0
              • markM
                mark
                last edited by

                Dear @tadakan,

                Well, by "image file" I think you mean a media index -- i.e., a number. Javascript would not have the capability to access the necessary information from that number to give  you the duration I'm afraid.
                Best Wishes,
                Mark

                Media Artist & Creator of Isadora
                Macintosh SE-30, 32 Mb RAM, MacOS 7.6, Dual Floppy Drives

                1 Reply Last reply Reply Quote 0
                • T
                  tadakan
                  last edited by

                  Thanks Mark, that's what I meant, thanks for translating my thoughts.

                  Tom

                  OSX 10.11.6 on 15" rMBP from Oct. 2014. 2.5ghz i7 16gb ram.

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