PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: blackwings on 16 November, 2004, 12:34:25

Title: help with a small "loading" question
Post by: blackwings on 16 November, 2004, 12:34:25
How do you code so that another .lua folder in a subfolder gets started and loaded into ptokax,
as if it were located in the script folder?
Title:
Post by: nErBoS on 16 November, 2004, 13:08:01
Hi,

You can use the function...

dofile("PATH")

..you can also use a combination wiht the assert function to appear what ever you want in the script editor if the function dofile returns nil...

asset(dofile("PATH"), "FILE NOT FOUND")

Best regards, nErBoS
Title:
Post by: blackwings on 16 November, 2004, 13:39:51
should I put it in main() or in the DataArrival()?
Title:
Post by: Psycho_Chihuahua on 16 November, 2004, 13:49:04
asset(dofile("PATH"), "FILE NOT FOUND")

should work if you put it in before anything else  :D

first asset then Main() then DataArrival()

Thats how i did it.

Hope it helps u 2
Title:
Post by: Herodes on 16 November, 2004, 21:49:03
assert(some_condition, error_message)

the assert function is used for checking if the "some_condition" ,
which means stuff like  type("is this a string") == "string".
If the "some_condition" part isnt "true" then it halts execution,
of the function, and issues an error_message.
The error message has to be a returned or resolved string and can be customised.

thats just spreading lua around.. :)
Title:
Post by: ((UKSN))shad_dow on 16 November, 2004, 22:10:23
well heres how i added my addons folder aka other scripters scripts with out moding there code


Scripts = {  ["foldername/Scriptname.lua"] = 1 , ["foldername/Scriptname2.lua"] = 1
    }


function Main()

for i,v in Scripts do
if v == 1 then  
assert(dofile(i), i.." is not found")    --//loads all scripts in the scripts array
end
end

end

yours
shad