How to import another Lua script to main Lua script

How i can import another lua script?

I trying write

MyLib = require('MyLib.lua')
MyLib.DoSomthing()

But it isn’t work

Lua: ./scripts/testScript.lua:1: attempt to call a nil value (global ‘require’)

Not supported in the current state of ArduPilot’s Lua engine.

1 Like

I see, thanks for the answer

It seems this topic may be relevant. I will be checking to see how it works. if we can include files somehow it will make Lua so much more powerful. Now I am forced to duplicate large chunks of code.

Modular lua scripts - ArduPilot Lua Scripting - ArduPilot Discourse