Skip to content
/ war3-lua-seed Public template

A Wc3 map project seed using Lua scripting language that allows code splitting and editing code while the World Editor is open. Powered by Node.js.

Notifications You must be signed in to change notification settings

vitorTheDev/war3-lua-seed

Repository files navigation

🌑 Warcraft 3 Map Project Seed With Lua

A Warcraft 3 map project template using Lua scripting language that allows code splitting and editing code while the World Editor is open. Powered by Node.js.

Features

  • Bundling and code splitting (via Luabundle)
  • File watcher (via nodemon)
  • Bundle contents of the src/ (and lib/ for external libraries like damage-engine.lua) folder and inject them in the map.w3x/war3map.lua file
    • Thus enabling editing the map using the World Editor whilist editing lua with code editors like VSCode without having to neither copy/paste code in the editor nor create a clone project
    • See Caveats
  • Code minification using Luamin
  • Bundle file size check (warning if > 100KB)

Installation

Usage

Development

  • run npm start to bundle and watch for changes
  • run npm run bundle to bundle only

Production

  • run npm run bundle.prod to watch for changes with minification enabled
  • run npm run watch.prod to watch for changes with minification enabled

Caveats

  • Map bundle injection or loading may fail if:
    • Run Map immediatly after save: World Editor saving takes a small amount of time, and change detection / bundling also has a small execution time. So if you test the map before bundling is done it won't work. Wait a few seconds after save or wait for the bundling complete message in the console
    • TestMap used istead of map.w3x/: Unsaved changes in the World Editor cause it to create and run a temporary map TestMap. Since the path to TestMap is not known, it's not injected with lua bundle. Workaround: If you change anything in the World Editor (an asterisk appears on the World Editor window label map.w3x*), then you need to first SAVE in the editor and wait for change detection + compilation (~ 1 second) before clicking Test Map
    • Map save detection fails: watcher not runnig / watcher didn't wait before map save was complete (thus bundle was overwritten)
    • Write was denied: map.w3x/war3map.lua file is in use by another process or has read only permissions
  • Files not required by the src/main.lua (__root) module or it's submodules are not included in the bundle, thus not acessible anywhere (including external libs at lib/)

Enhancements to consider:

  • Map source backup option
  • Use lua Global Initialization instead of hooks
  • .env or equivalent
  • Fix TestMap TempFolder caveat
  • Make it easier to include external Lua libraries
  • Typescript to Lua
  • Make into npm package
  • Make into npm package
  • Create release mode that minifies the map completely (smaller) but is irreversible, and should instead create a new file in a /dist folder or create a backup file

License

MIT

About

A Wc3 map project seed using Lua scripting language that allows code splitting and editing code while the World Editor is open. Powered by Node.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published