Battlezone 98 Redux

Battlezone 98 Redux

Not enough ratings
RequireFix
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
983.733 KB
24 Jan @ 11:41am
27 Jan @ 2:44pm
3 Change Notes ( view )

Subscribe to download
RequireFix

Description
Usage:

This mod lets mapmakers load lua modules from anywhere in their workshop directory. This allows you to create dependencies on a centralized platform, or load DLLS which do not load normally in stock bz lua.

To enable this mod, ship your mod with "RequireFix.lua" and place these two lines of code at the top of your map script, or before you attempt to load an external module. Place the workshop ID of the desired item as the argument of the Initialize() function. If you have multiple items, construct a table with the workshop IDs and pass the table into the function.

ex.

``` lua
local RequireFix = require("RequireFix")

-- Single item example:

-- exposes any files at this workshop ID to the require function...
RequireFix.Initialize(3144751838)
-- that number is the ID for the extra utilities mod
local exu = require("ExtraUtils")

-- Multiple items example:

-- these are just random mods, don't actually use these lol
local myWorkshopMods = {2762060483, 2972946986, 3144751838}
RequireFix.Initialize(myWorkshopMods)
require(whatever files were in the mods you loaded)
```

After initializing RequireFix, you are able to require() your mods without issue. Do that underneath the initialization. The order of these operations is very important, remember: require("RequireFix") first, then Initialize(your workshop IDs), then require(your external modules)

You can also add a check to verify if the DLL functions have loaded correctly, prior to the mission using them. Add this to the top of your code instead of the RequireFix lines above:

local RequireFix = require("RequireFix")
RequireFix.Initialize(3144751838) -- This is the workshop ID for extra utilities
local success, exu = pcall(require, "ExtraUtils")
local exuPresent = false
if success then
-- The module was successfully loaded
print("ExtraUtils module loaded successfully")
exuPresent = true
-- Now you can use 'exu' as needed
else
-- An error occurred during the require statement
print("Error loading ExtraUtils module:", exu)
-- Handle the error or provide a fallback mechanism
end

Then add this to your function Start()

if exuPresent then
exu.Start()
else
FailMission(8,"noexu.des")
end

Module by:
- DivisionByZero
- GrizzlyOne95
- VTrider

If you would like to report an issue or request a feature, contact me on discord at "vtrider", or join the battlezone community discord at discord.gg/battlezonestrategy.
Popular Discussions View All (1)
9
18 Apr @ 1:25pm
Broken for GOG players
Nielk1