Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Indaxia/wc3-wlpm-module-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Caution

WLPM IS DEPRECATED - USE Module Manager for IMP

Warcraft 3 Lua Module Manager (like ES6)

Provides functions to create and use ES6-style modules in Warcraft 3 lua code. WM means Warcraft Module.

Modules let you write componentized and sharable code. WLPM Module Manager allows you to declare your modules in any order. It arranges everything for you: dependency tree, loop detection, lazy loading etc.

How to install

Example Usage

-- file1 (or Custom Script 1)
WM("myMainModule", function(import, export, exportDefault) -- declare your main module
    local greeting = import "helloModule" -- use default export value
    local anotherGreeting = import("welcome", "helloModule") -- use custom export value
    local coffee = import "coffeeModule"
    local anotherCoffee = import("cappuccino", "coffeeModule")
    
    print (greeting)
    print (anotherGreeting)
    print (coffee)
    print (anotherCoffee)
end)

-- file2 (or Custom Script 2)
WM("coffeeModule", function(import, export, exportDefault) -- declare your module
    exportDefault "Espresso!" -- declare default export value
    export("cappuccino", "Your cappuccino, sir!") -- declare custom export value
end)

-- file3 (or Custom Script 3)
WM("helloModule", function(import, export, exportDefault) -- declare your module
    exportDefault "Hello!" -- declare default export value 
    export("welcome", "Welcome!") -- declare custom export value
end)

-- call your main import from triggers on MAP INITIALIZATION or anywhere
importWM("myMainModule") 

Result:

Hello!
Welcome!
Espresso!
Your cappuccino, sir!

Advanced Usage

-- advanced export
WM("coffeeModule", function(import, export, exportDefault) -- declare your module
    exportDefault "Espresso!" -- declare default export value
    export { -- declare multiple custom export values
      "cappuccino" = "Your cappuccino, sir!",
      "macciato" = "One nonfat macchiato",
      "someFunction" = (function() return "something" end)
    }
end)

-- initialize modules before call and (or) without getting values
WM("myMainModule", {"helloModule","coffeeModule"}, function(import, export, exportDefault) 
    
end)

-- Disable lazy loading and load all modules instantly
loadAllWMs()

ScorpioT1000 / 2019

About

Warcraft 3 Lua Module Manager (like ES6)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages