Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
W3LuaEnv is a free tool that enables modular programming in Lua without needing to close the World Editor. Simply select your main script (defining the project directory), and W3LuaEnv will automatically monitor changes to your code in the background, preparing the final script for integration.
By detecting require statements in your code, the tool automatically manages dependencies between modules. When you're ready to test, just press F9 in the Trigger Editor, and W3LuaEnv will export and execute the updated code in your .w3m map—no extra steps needed.
Lua:
--main.lua
local mod = require('module')
local timer = CreateTimer()
TimerStart(timer, 0, false, function()
mod.say_hello()
end)
Lua:
--module.lua
M = {}
function M.say_hello()
print('Hello!')
end
return M
The require statement can be used in any module of the project, and the modules can be structured into subfolders. You can have a really complex and well-organized codebase.
The module system adheres strictly to standard Lua practices. Specifically:
When using require, the module can be assigned to a variable or simply executed, with the assignment being optional.
Requiring the same module multiple times does not trigger its re-execution, as it is loaded only once and stored in an internal cache. This allows you to reference the module anywhere in your code without overhead, since the preloaded module is returned preserving its state.
You can organize your code into multiple modules distributed across subfolders within your project's directory. This structure enhances code management and scalability, enabling developers to work more efficiently and maintain a clean codebase.
You can edit your modules with your favorite code editor while working with the World Editor. W3LuaEnv will run in the background, allowing for a smooth workflow.
I hope you find this useful, even though I know many of you prefer JASS. I welcome any suggestions and encourage you to report any errors or provide feedback.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.