Reputation: 8533
This looks very simple but has me stumped, I have a function like this:
print_stuff = (name) -> name
defined in a folder called pale_moonlight
so it's here: pale_moonlight/function.moon
. When I try calling it like this:
> f = require 'pale_moonlight.function'
> f.print_stuff 'lolo'
I get the error below:
[string "tmp"]:1: attempt to index global 'f' (a boolean value)
What is the proper way to do this? My moonscript version: 0.2.6, lua version: 5.2.3
Upvotes: 1
Views: 469
Reputation: 811
The last line of your file should be { :print_stuff }
. This is MoonScript for: return { print_stuff = print_stuff }
and allows the function to be accessed through the table that would be returned by require
.
Upvotes: 4