PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: blackwings on 07 May, 2005, 16:05:44

Title: problem with loading files
Post by: blackwings on 07 May, 2005, 16:05:44
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
Title:
Post by: Dessamator on 07 May, 2005, 16:35:02
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
Title:
Post by: blackwings on 07 May, 2005, 17:55:02
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 :)
Title:
Post by: Dessamator on 07 May, 2005, 18:30:13
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
Title:
Post by: ??????Hawk?????? on 07 May, 2005, 18:31:37
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..
Title:
Post by: Dessamator on 07 May, 2005, 18:43:25
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, :)