jprbest
jprbest

Reputation: 737

call function in lua from different lua class

I have a function

function f1(msg) return value end

in Lua file A.lua, how i can call this function or the return result of this function from a B.lua Thank you Jp

Upvotes: 2

Views: 3442

Answers (2)

ashen
ashen

Reputation: 827

As a complement to brianm, you can also

dofile("A.lua")
f1("blah")

or

local chunk = assert(loadfile("A.lua"))
chunk()
f1("blah")

Upvotes: 1

brianm
brianm

Reputation: 2045

You use the require function ( http://www.lua.org/pil/8.1.html )

require("A")
f1("my message")

Upvotes: 6

Related Questions