Project Zomboid

Project Zomboid

Moodles in lua [B42]
 This topic has been pinned, so it's probably important
molecule31  [developer] 14 Jan @ 4:04am
How to make your mod compatible
Here is example zip archive with working mod that add moodle icon set to list:
https://molecule31.co.ua/notindex/steam/moodlesinlua/example.zip

Step 1: Prepare Your Textures

To integrate your custom textures with the Moodles In Lua, follow these steps to organize your files and ensure everything is correctly set up.

I. Create new folders

First, create a new folders for your texture pack. The structure should look like this:

├── 42 │   ├── icon.png │   ├── mod.info │   └── poster.png │ └── common └── media │ ├── lua │   └── client │   └── YOURNAME.lua └── ui ├── MIL │   └── YOURNAME │   └── *copy only textures from 128 folder* └── Moodles ├── 128 │ └── *moodle textures* └── 96, 80, 64, 48, 32

Replace YOURNAME with the name of your mod. It’s a good practice to use simple alphanumeric characters and avoid spaces or special characters in the folder name.

II. Texture Organization

Depending on the type of textures you're adding, you need to organize them as follows:

Icons: Simply copy your moodle textures from folder 128 into the MIL/YOURNAME folder.

Borders: Border textures should follow a specific naming convention based on their type (positive/negative) and level. For example:

- Positive Borders: good_1.png, good_2.png, good_3.png, good_4.png
- Negative Borders: bad_1.png, bad_2.png, bad_3.png, bad_4.png

Important Notes:

Each texture should be at least 128x128 pixels in size. If you make the textures larger (for example 128x138 or 112x128), they will adjust to a wider or shorter size, respectively. However avoid making them too small or too big

If your textures exceed the screen space or appear too small/large in the game, this can be corrected by modifying the script as needed.

Step 2: Register Your Textures

After you’ve prepared your textures, you’ll need make them visible to the mod so they can be used. This is done by creating a script that registers your texture set in the mod.

I. If You Are Registering Icon Textures

Open file that you created earlier YOURNAME.lua

Here's the example script that register your icon texture set:
if ISMoodlesInLuaHandle == nil then return end -- do not remove this local name = "YOURNAME" -- Name of your texture set local path = "media/ui/MIL/YOURNAME" -- Path to your textures ISMoodlesInLuaHandle:registerIconTextureSet(name, path)

Replace "YOURNAME" with the name you want to give your texture set and path should be same as you made earlier so it points to folder with your textures

II. If You Are Registering Border Textures

If you are registering border textures instead of icon textures, replace registerIconTextureSet with registerBorderTextureSet in the script.
Here’s how the script would look:
if ISMoodlesInLuaHandle == nil then return end -- do not remove this local name = "YOURNAME" -- Name of your texture set local path = "media/ui/MIL/YOURNAME" -- Path to your textures ISMoodlesInLuaHandle:registerBorderTextureSet(name, path)

Also, I mentioned earlier that if your borders don't quite match the layout you would like, you can change that

Here's the parameters that you can change:

moodleOffsetX
Default: 0, Adjusts the horizontal position of moodles (X-axis offset)

moodleOffsetY
Default: 0, Adjusts the vertical position of moodles (Y-axis offset)

iconOffsetX
Default: 0, Adjusts the horizontal position of the moodle icon (X-axis offset)

iconOffsetY
Default: 0, Adjusts the vertical position of the moodle icon (Y-axis offset)

moodleAlpha
Default: 1.0, Controls the overall opacity of the moodles (Alpha transparency level)

moodlesDistance
Default: 10, Sets the space between moodles

tooltipPadding
Default: 1, Defines the padding inside the tooltip for spacing around the text

tooltipOffsetX
Default: 5, Can be used to add a larger gap between the tooltip and moodle



How do I change this?

You will need to create a new line local options {} and change ISMoodlesInLuaHandle:registerBorderTextureSet(name, path, options) - we added options

For example, I want to change the distance between the moodles and place them a slightly left, this is how it will look like:
if ISMoodlesInLuaHandle == nil then return end -- do not remove this local name = "YOURNAME" -- Name of your texture set local path = "media/ui/MIL/YOURNAME" -- Path to your textures local options { moodleOffsetX=-8, moodlesDistance=15, } ISMoodlesInLuaHandle:registerBorderTextureSet(name, path, options)

Step 3: Finalizing and Testing

After setting up your textures and registration script:

I. Ensure the mod is loaded
Important! Your mod should be placed under the Moodles In Lua in the mod order to load correctly, also If you're making border textures, you can add the following line to your mod.info file:
require=\moodlesinlua
This ensures that Moodles In Lua is installed and enabled, and it will automatically position your mod correctly in the mod order

II. Test your textures
In the game settings menu, you should see the MODS tab, within this tab, look for Moodles In Lua and If everything is done correctly, your texture pack will appear in the list under the name you've registered for your pack

III. Troubleshooting:
If textures don't appear as expected, double-check the path to the texture files in your registration script

Make sure all texture files are correctly named and located in the specified directory
Last edited by molecule31; 2 Feb @ 11:10pm