• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Modules for Wc3 Lua

Status
Not open for further replies.
Since Lua is coming to Warcraft 3 and Lua IO is not supported, it would be a hassle breaking the reknown Lua modules which could be helpful in Wc3 Lua modding, so I wrote a module system for Lua.

There are two module systems I designed: a dependent module system, and an asynchronous module system:

Example DMS:
Lua:
module.create("A")(function ()
  print("module A loaded")
  return 100
end)
module.create("B")(function ()
  print("module B loaded")
  return 200
end)
module.create("C")(function ()
  print("module C loaded")
  return function (a, b)
    return a + b
  end
end)
module.create("D", {"A", "B", "C"})(function (imports)
  print("module D loaded")
  return imports.C(imports.A, imports.B)
end)
module.create("E")(function ()
  print("module E loaded")
  return print
end)
module.create("F", {"D", "E"})(function (imports)
  print("module F loaded")
  imports.E(imports.D)
end)
module.init()

Example AMS:
Lua:
module.create("A", function() return 100 end)
module.create("B", function() return 200 end)
module.create("add", function ()
  return function (a, b)
    return a + b
  end
end)
module.create("print", function ()
  return print
end)
module.create("addAB", function (require)
  local A = require("A")
  local B = require("B")
  local add = require("add")
  return add(A, B)
end)
module.create("init", function (require)
  require("print")(require("addAB"))
end)

module.load("init")

Here's the repo link: LXSMNSYC/Lua-Wc3-Module
 
Last edited:
Status
Not open for further replies.
Top