How to add new lua?

Home Forums General Programming How to add new lua?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #71365
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    hi,
    i’m probably at an ‘rtfm’ stage but i’ll ask for guidance anyway:
    i have 2 forms of the lua method to try out, one ‘long’ and the
    other ‘proper’ one that was suggested to me by dasfaker.

    i’m unsure how to Add a New Method.
    1/ first, i have the text files in a folder.
    2/ at the Resources tab, i’ve done ‘Add’, and found the text file.
    3/ i have disabled the MIDI message entry, from ‘sysex’ to ‘none’
    4/ at ‘Called when the Modulator Value changes’, i could not find
    the new Resources entry, so i clicked ‘Add New Method’ and pasted
    the name of the new Resources Tab entry.
    5/ i clicked ‘Edit Selected Method’, and there i see only the default
    display.

    ok, so this looks like:

    --
    -- Called when a modulator value changes
    -- @mod   http://ctrlr.org/api/class_ctrlr_modulator.html
    -- @value    new numeric value of the modulator
    --
    D110 partial lua dasfaker = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
    end

    see image ‘add new method 1’
    the top bar is highlight in red; red, to me, is ‘warning’/wrong/error,
    so that doesn’t look like it’s right yet.
    it refers to the the method, but i still need to do something.
    i think i need to copy in the body of my new method.

    so i check the Built In methods shown on the left pane:
    expand tree, and it appears i must doubleclick on an item to bring it
    up in the editor view. indeed. so that is what my new method should
    look like, and its tab is white/clear, compared to the red tab i have
    for my method.

    so:
    6/ i copy the content of my text file between ‘function’ and ‘end’.
    >the tab is still red.
    >see image ‘add new method 2’

    ?…headscratch. wonder what’s missing, oh look:
    ‘File’ options: Save/Save and Compile/Save and Compiile All

    7/ lets try Save and Compile…’FAILED’
    >see image ‘add new method 3’
    OK, so i did try this with my ‘longer’ version of the method
    before, and i think i did a bit better including the brackets and
    end etc. that i had copied from the method i’d cribbed from, because
    at this point, i got back ‘OK’.
    i half expected this result, and i know that my Panel names don’t
    correspond yet with the modulator titles in the lua. so i did half
    expect this, and i’m quite happy in fact that it is different from
    my first attempt, because it shows i’m on the right track.

    i close Ctrlr now to start again with the other one, and clear the
    result box – it keeps previous results, i don’t know how to clear
    it – let’s hope Ctrlr doesn’t autosave what i just did…so:

    8/(restart)i go back to my long method, and copy’all’from the text file,
    over what is in the editor,including header, do save and compile, and
    HA HAA.. get OK! > bomshakalaka… 🙂

    and…oh wow: the tab is now WHITE, clear. yesss, this was successful.
    so that is how you do that bit. here’s what that looks like>image,
    add new method 4.

    now, when i tried this yesterday, i got no MIDI output to midiox.
    this is what i need to sort out. also need some clarifcation on
    some of this stuff, i’ve never compiled jack, and don’t know what
    debugger, find and replace, output etc. are, or what to expect.
    (and i’m documenting this for future newbies of course)

    end of opening post !!

    however

    Attachments:
    You must be logged in to view attached files.
    #71371
    proton
    Participant
    • Topics: 19
    • Replies: 94
    • Total: 113
    • ★★

    Hi human fly,

    minor changes to the method and all works well.
    I tried to explain in the picture below but ask if something need explanation.
    Cheers!

    Attachments:
    You must be logged in to view attached files.
    #71375
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    hey *great* ! thanks, and to everybody for your help !

    i did get ONE message at some point this morning messing
    around with it, but i don’t know how 🙂

    if it was just elimating that space..but that makes me
    nervous about creating indents lol. i need some basics
    about what spaces are needed, what certain characters
    do, that kind of thing.

    this is very encouraging. hehe.
    i will attempt the same thing with dasfaker’s more optimised
    solution later this evening; maybe you can check that out
    for me too.i think this will be a good demo prefab for others,
    as it is such a tricky sysex issue as well. you very rarely
    find parameters with this kind of problem to overcome.
    eg: ‘interdependent bitflipping’ is a good term.

    i find the adding of a method quite weird: you add the text
    file to resources, but then i still had to copy it’s contents
    into the lua editor page (and i’m still unclear what is vital
    in that header). and re-enter the name, and then ‘save and compile’,
    and even when it told me ok, it wouldn’t do it.

    great! thanks again, i’ll be back later to attack this.

    • This reply was modified 5 years, 3 months ago by human fly. Reason: typo again
    #71379
    goodweather
    Participant
    • Topics: 45
    • Replies: 550
    • Total: 595
    • ★★★

    Hi human fly, please read and have a look at my Ctrlr Step by Step Guide.

    I started a v2 containing much more and better explanations based on my DSI Pro2 panel and a lot of Lua but don’t find the time to complete it yet. Will have to wait some business trips and long nights at the hotels…

    #71380
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    great thanks. i think you were doing the sub37 before?
    about a year ago. lost my HDD since then, so i redownloaded.
    my priority then was learning to navigate Ctrlr itself and
    see how far i could get with the UI

    business trip? that reminds me of living in a squat in spain
    with an austrian beggar, and his german friend roland, also
    a beggar, talking about heading up the coast to try another
    town, saying he was ‘going on a business trip’ 😉

    #71387
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    Hi human fly,

    minor changes to the method and all works well.
    I tried to explain in the picture below but ask if something need explanation.
    Cheers!

    thank you, i just got to check it. that’s really good.
    only checked with midiox so far.

    #71388
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    i tried to edit my method to be the same as yours with
    indents etc. – it saves and compiles OK but when i get
    to adding the second ‘end’ at the end, i get

    ERROR: [string "lua method Partials select v03"]:95: '<eof>' expected near 'end'

    and it fails.

    what does this mean? i’ve kept the same lua name i had before.
    yours is called the same as the function.
    (sorry haven’t read up yet, i’m just going through this parrot fashion
    for now, i will attempt the short version afterwards.)

    also: so a lua is not added at all on the Resources Tab, then?
    is that only for images? what else?

    • This reply was modified 5 years, 3 months ago by human fly.
    Attachments:
    You must be logged in to view attached files.
    #71393
    proton
    Participant
    • Topics: 19
    • Replies: 94
    • Total: 113
    • ★★

    Hi human fly,

    yes, you don’t need to add methods in Resources only assets you use in your panel, mostly PNGs, documents your script is accessing etc.

    Please read the manual the guys are working on. It will clear few things for you.

    Cheers!

    Attachments:
    You must be logged in to view attached files.
    #71404
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    ok well i’m chuffed to report that i’ve got both
    methods working hehe. yes, i’ve cleared up that misconception.

    adding a new lua is simple: you ‘add new method’, give it a
    name, and then go ‘edit method’, opens the lua editor, double click
    the newly added method, and do whatever you have to do to cobble
    together your lua.

    as for the results of the 2 methods, i’ll post about it on that topic.
    i did look at the manual, and i’ve seen it before. that was a good
    ‘practical’ though ! i’m encouraged by getting an early result, thanks
    to very effective assistance from you guys.
    long version is working as expected. optimized version needs a tweak,
    gernerally working but sends 3 sysex messages on panel load.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 78 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr