Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua require chunk environment

Tags:

require

lua

A required chunk runs in global environment by default.

Each loaded user script is setup to run in a sandbox and if the script happens to contain a require call, it will modify the global environment.

Is there a way to set that environment to the same one of the calling script?

like image 421
reiofspades Avatar asked Oct 20 '22 17:10

reiofspades


1 Answers

Yes, you can replace require with your own function.

The prosody XMPP server does this here.

like image 111
Etan Reisner Avatar answered Oct 22 '22 20:10

Etan Reisner