How to call functions from another lua file (not a different resource)

Title says it all.

I have “file 1.lua” and “file 2.lua”, I wish to call a function inside “file 2.lua” within “file 1.lua”.

Cheers.

Can you not just call the function? If its not a local function it should fire essentially right?

If it doesn’t you could make a global table

Utils = {}

then add a function to that…

Utils.NameOfFunction = function(args)
-- your code here
end

then just call Utils.NameOfFunction()

If I try to call the function from “file 1.lua” I simply get an error that the function doesn’t exist.
Here’s a better example:

file 1.lua

--Run function hello() from file 2.lua
hello()

file 2.lua

function hello() {
    print('Hello world')
}

That example is contrived and of course will only work if you define file2.lua before file1.lua in your resource manifest.

Oh. Right, I forgot about that part lol. Thanks.