Jump to content

can I include files into other files?


kuwalda

Recommended Posts

Is it possible to add up two files?

Like I have my checkpoints stored in tables and they take up way too many lines. Is it somehow possieble that I put all those tables in seperate file and use something like, in php function include? Or is there any other way?

Link to comment
  • Moderators
If you store your data tables in a seperate .lua file and write down the scriptfile in meta.xml then you should be fine. MTA does the "include" job for you.

only if the variable is a global one and is in the same side.

server1.lua

local localTable = { 1, 2, 3 } 
globalTable = { 4, 5, 6 } 

server2.lua

for k, i in ipairs (localTable) do --error, table undefined (nil value) 
    outputChatBox(i) 
end 
  
for k, i in ipairs (globalTable) do -- works 
    outputChatBox(i) -- prints 4, 5, 6 
end 

client.lua

for k, i in ipairs (localTable) do --error, table undefined (nil value) 
    outputChatBox(i) 
end 
  
for k, i in ipairs (globalTable) do --error, table undefined (nil value) 
    outputChatBox(i) 
end 

Link to comment
  • Moderators
only if the variable is a global one and is in the same side.

Basic Lua should be a minimum when you are going to script something.

client and server is not lua specific, and it's really an abstract thing when you start scripting for MTA.

So it's not as obvious as you think it was.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...