• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Shared config file

Sun

Knowledge is power - France is bacon
Joined
Jan 26, 2015
Messages
334
Solutions
22
Reaction score
249
Is there a way in lua to take info from a separate file?
I've got several scripts that have the same config and it's a pain to change things since I need to change it in several files.
 
dofile('data/...')
Exactly what I was looking for, thanks ^^

If anybody comes by looking for the same thing,
have in mind that local values can't be read by dofile.
For example:
local test = 333 -- will be ignored by dofile since it's a local value
test = 333 -- will return 333 by calling test using dofile as it's a global value

Example of how to use:

we have a movement script named a.lua

Code:
shared = 3381

function onStepIn(cid, pos, fromPosition, toPosition)
    dosomething
    return true
end

and a talkaction named b.lua

<talkaction words="!b" script="b.lua"/>

Code:
dofile("data/movements/scripts/a.lua")

function onSay(cid, param, words, channel)
    doCreatureSay(cid, '' .. shared .. '', 19, false, cid)
    return true
end

now when we write !b it will say 3381 in orange text
 
Exactly what I was looking for, thanks ^^

If anybody comes by looking for the same thing,
have in mind that local values can't be read by dofile.
For example:
local test = 333 -- will be ignored by dofile since it's a local value
test = 333 -- will return 333 by calling test using dofile as it's a global value

Example of how to use:

we have a movement script named a.lua

Code:
shared = 3381

function onStepIn(cid, pos, fromPosition, toPosition)
    dosomething
    return true
end

and a talkaction named b.lua

<talkaction words="!b" script="b.lua"/>

Code:
dofile("data/movements/scripts/a.lua")

function onSay(cid, param, words, channel)
    doCreatureSay(cid, '' .. shared .. '', 19, false, cid)
    return true
end

now when we write !b it will say 3381 in orange text
Welcome to global variable world.
 
Back
Top