I have a problem with using/loading files in lua. I have tried to use assert, dofile and readfrom etc which I have seen in other scripts, but failed to get it to work.
So can anyone help me, what should I do to get a seperate .lua file in a sub folder to be loaded with a script, which contains a lua function?
Like the lua file is in ../scripts/others/extra.lua
with a contents of a lua function like this for example =
function example(user,data)
user:SendData(Bot, "example")
end
dofile("others/extra.lua")
that should work, :)
but only if the code is something like this:
[COLOR=red]Bot=frmHubGetHubBotName()[/COLOR]
function example(user,data)
user:SendData(Bot, "example")
end
hmm, so you mean with the "Bot=frmHubGetHubBotName()", that I need to make the extra.lua like a stand alone script? Hmm, to bad, I thought I could just put a function in a seperate file and it would work as good as if it was in the main lua file :(
Anyway, thanx for your help, I will try this later today :)
or u can try it like this example::
function NewUserConnected(user)
dofile("test2.lua")
Bot=frmHub:GetHubBotName()
example(user,data)
end
and the lua function file ::
function example(user,data)
user:SendData(Bot, "example")
end
hi m8
Quotehmm, so you mean with the "Bot=frmHubGetHubBotName()", that I need to make the extra.lua like a stand alone script? Hmm, to bad, I thought I could just put a function in a seperate file and it would work as good as if it was in the main lua file :(
NO you dont need to make them stand alone...
eg.. you could have all functions in one file..
user commands in another ..
and tables in another .
and assert all three in the main lua file..
QuoteOriginally posted by ?˜”??•Hawk•??”˜?
hi m8
Quotehmm, so you mean with the "Bot=frmHubGetHubBotName()", that I need to make the extra.lua like a stand alone script? Hmm, to bad, I thought I could just put a function in a seperate file and it would work as good as if it was in the main lua file :(
NO you dont need to make them stand alone...
eg.. you could have all functions in one file..
user commands in another ..
and tables in another .
and assert all three in the main lua file..
indeed, :)