Gaimo Posted May 17, 2020 Posted May 17, 2020 Como deixar um arquivo só para useful functions, outro arquivo para variáveis e usar em um script main? usefulfunctions.Lua vars.Lua main.Lua
DNL291 Posted May 17, 2020 Posted May 17, 2020 Nada te impede de te fazer isso, apenas tenha em mente que para uma função/variável poder ser acessada por outro arquivo de script ela não pode ser local.
Gaimo Posted May 18, 2020 Author Posted May 18, 2020 meta.xml Spoiler <meta> <info author="Gaimo"/> <script src="c.Lua" type="client"/> <script src="s.Lua" type="server"/> <script src="vars.Lua" type="server"/> </meta> vars.Lua Spoiler vartest = 130 vartest1 = "Hello world" tabletest = { {123}, {321}, } s.Lua Spoiler print(vartest) ok = vartest1 print(ok) var1 = tabletest[1] var2 = tabletest[2] print(var1) print(var2) print(tabletest[1]) ERRO: INFO: nil INFO: nil attempt to index global 'tabletest' (a nil value) O que eu fiz de errado?
main Posted May 18, 2020 Posted May 18, 2020 Coloque para ler primeiro o arquivo que contém as variáveis globais <meta> <info author="Gaimo"/> <script src="c.Lua" type="client"/> <script src="vars.Lua" type="server"/> <script src="s.Lua" type="server"/> </meta>
Gaimo Posted May 19, 2020 Author Posted May 19, 2020 Essas vars só poderão ser usadas nesse resource né?
main Posted May 19, 2020 Posted May 19, 2020 3 hours ago, Gaimo said: Essas vars só poderão ser usadas nesse resource né? Sim.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now