Помощь - Поиск - Пользователи - Календарь
Полная версия: Импортировать код из другого скрипта/файла | Import code from another script/file
UoKit.com Форумы > Кликер > UO Pilot
neves
Hello, everyone.
I have very long script with many functions at the beginning of the script.
Is there a way to put these functions in other script/file and somehow to import only the file in the given script.
I am using lua syntax.
Thank you, and have a nice day.
cirus
Next to the exe, create a file with any name, for example: function1.lua.
With one or more functions:
Код
function my_func()
    log (111)
end

Use in the script:
Код
--lua
require("function1")    -- download the function

my_func()  -- called function
neves
Awesome! Works great.
Does require() works with path or subdirectory?
cirus
Цитата
Does require() works with path or subdirectory?

Код
--lua
package.path = "C:\\folder\\?.lua;" .. package.path  -- path to the file with the function  'C:\folder'
require("function1")   -- download the function

my_func()  -- called function
Это текстовая версия — только основной контент. Для просмотра полной версии этой страницы, пожалуйста, нажмите сюда.
Русская версия Invision Power Board © 2001-2024 Invision Power Services, Inc.