assurance-tunnel
assurance-tunnel
assurance-tunnel
assurance-tunnel

Javascript - Custom file path



  • Hi there all,

    The Javascript actor is something that I use quite often. The thing that is making it a bit of a frustating experience for me as an artist is that the IDE that is provided is not optimal at all. 

    I would love to see a way to load in external files by either a External File bin or by a external file path. (Like the Data Array). That way I can use my own IDE (Sublime Text) that has some core features that are currently missing in the IDE.



  • Hello @Juriaan,

    I'm not sure if it is what you need. But I already do read text files with Javascript. I just use 

    var txt = read (arguments[0]);

    and put the file path into the input.

    This reads the whole file into the variable for further use.

    I did a reader that can load EDL (edit lists from Timeline based Video edit Software) and working now on reading Subtitle texts.

    https://community.troikatronix...

    Best

    Dill

    Edit: corrected code



  • Hi there,
    No, I was not talking about TXT files, I wish to load in a JavaScript file, and I believe this is more of a User Experience request ;)

    - Juriaan



  • For example a pain is in the current IDE is that if you wish to tab a few lines of code your entire code will be removed.


    Steps to recreate :

    - Select a few lines of code

    - Press tab

    - Boom. Your code is gone.

    While in other IDEs you can do that just fine, and it will add a proper tab before the lines that you selected.



  • @juriaan, I got you now.

    What you want is more script editor functions!? Maybe for now you could use a separate script editor with special functions and always copy - paste the whole script. I use Atom on OSX. It does have a lot of plugins for special features like the ones you mentioned.

    Edit: Ok, you just want to avoid the copy - paste and have Isadora load the Javafile in realtime?



  • Yep. I want to press Save in Sublime Text or Athom, and that Isadora will load in the new file ;)


  • Tech Staff

    @dillthekraut

    You may find this script useful: https://community.troikatronix...


  • Tech Staff

    @juriaan

    In Javascript we have 2 methods for loading external files.

    Read(), and Include().

    with Include(), it reads and parses the text with the Javascript engine, and the text must be valid javascript (as used in: https://support.troikatronix.c...)

    SO, you can simply enter into a JS actor:

    include('mycode.js');

    and that single line will load your external script and have the JS engine parse it.. of course it needs to include a main() etc..
    Then you can work in your code editor (sublime text) along side Isadora. When you save in Sublime, you will need to have Isadora refresh the 'include'.
    There are 2 ways to do this, that I know of. 
    1: exit and reenter the scene.
    2: Use a 'User Actor on/off' to toggle the state of the scene (forcing a refresh) (this actor is not available in the main scene level, but can be cut and pasted from a user actor..  very handy)

    Of course this is not seamless integration, but it works pretty well.
    I would also like to see the option of a JS actor where the required input is a file name/path and a trigger opens your code editor of choice (from preferences).