Lua, Require, Available Functions

If I have requirethree included files in my Lua script, can any function in any of these files see (and, most importantly, call) any of the other functions?

I ran into a problem of functions calling functions calling other functions. I tried to put various functions in other files, and then includeinstead of writing them to the main file.

I think this works, my tests are convincing, if not final.

My main code does this ...

 require "SOME_REQUIRED_FILE_01"
 require "SOME_REQUIRED_FILE_02"
 require "SOME_REQUIRED_FILE_03"

 XYZ = 0

 File_02_Function_A()

I looked at the Lua site and found THIS PAGE but I do not quite understand this.

Can EACH function in all three required files see EACH OTHER function in all three files?

+4
1

require , dofile, , ( , ). , ( ). , , require. .

, required. , . :

local some_required_file_01 = require "SOME_REQUIRED_FILE_01"
local some_result_01 = some_required_file_01.some_function_01()
+4

Source: https://habr.com/ru/post/1538125/


All Articles