Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Can’t quiet understand how to use external libraries like “moses”. require fails with not found

Hello! I’m new to Codea, recently bought it on iPad.
I like library moses very much, it has many many utilities to work with arrays, tables, types etc.

But I cannot understand how to use it inside Codea

I copied code from github project and inserted it into tab “moses”

Then I tried local _ = require “moses” and Codea gave me error “module not found”

What did I wrong?

Comments

  • Posts: 2,020

    If you have moses as a tab in your project, then you shouldn't need to import it with require. What happens if you just try one of the code samples from the moses tutorial in your project?

    I'm a big fan of functional programming, but not sure I like the _. namespacing that this library uses.

  • Posts: 3

    @yojimbo2000 hey, thanks for the answer!

    I tried using it via _, also tried in moses source code write moses = _

    (_ is local in moses file and I tried to make global variable)

    About _ - it’s taken just from underscore js, not a convention, more like a style or something. Everyone can use it with any symbol he/she wants.

    Anyway, even after trying to make global or use with _ I’m getting error attempt to index a nil value global _ or “moses”

    Maybe I do not understand how “tabs” in codea works, etc? Unfortunately moses does not have globalize manual :(

  • Posts: 3

    update:

    actually, globalization of _ worked

    I just tried to use code with _ outside of setup function, but I should’ve used it inside that function.

    So... I guess problem solved!

  • dave1707dave1707 Mod
    Posts: 6,993

    @idchlife Can you post a sample showing what you did so others can try it.

Sign In or Register to comment.