Project Zomboid

Project Zomboid

Restore Utilities
 This topic has been pinned, so it's probably important
Jackd44  [developer] Apr 30, 2024 @ 11:47pm
(Guide) Adding additional repair zones
Method 1: Using Admin mode (MP)/Debug Mode (SP)

This is by far the easiest way to add extra squares where you can repair at, the downside to this is that you must physically go to each location and right click each individual square where you'd like repairs to be possible. Also, this must be done on each and every new save.

Using Admin mode (MP)

If you're running a server I'm going to assume you already know how to give yourself admin powers, if you don't I'm sure a quick google will be able to help you out.

To assign squares as repair zones, simply right click on the square you wish to set. The right-click menu should have "[RU] Admin menu" near the top, simply hover over this to get a choice on whether to enable power or water repairs on this square, then click the option you'd like to pick.

If you set the wrong square by accident, simply click on the square again and go to "[RU] Admin menu" > "Disable repairs here" and click that, this will remove this square from the list of squares you're allowed to repair at.

Using Debug mode (SP)

In singleplayer, the process is almost exactly the same as in multiplayer, the only difference is you must be in debug mode instead of in admin mode. To enable debug mode simply add "-debug" (without the "s) to the command line, which can be done by right-clicking zomboid on steam and going to properties. If you're still unsure on how to enter debug mode, perhaps try googling it, I'm sure there will be more helpful guides there.

Once in debug mode, refer to the section above about setting squares from in admin mode, it works exactly the same.

Method 2: Using lua

This part is a bit more advanced, however I have created a template file which might hopefully help you if you're unfamiliar with lua. The file can be found in the mod's files under RestoreUtilities/media/lua/server/RU_addZonesTemplate.lua

Using the template

I tried to explain the template as best I could to help you understand even if you've never used lua before. You may open this file with any text editor, even notepad. However I personally prefer Notepad++ because it makes the file a bit easier to read.

If you plan on using the template, the very first thing you need to do is delete the first set of -- that appear on the very bottom line (right before "Events.OnInitGlobalModData.Add(onSaveLoad)"), if you don't do this the script will not run.

After that, if you want to add a custom square, or multiple squares, all you need to do is find the line that says "{X = 0, Y = 0, Z = 0, utilityType = "Elec"},". You may simply change the X, Y and Z coordinates to the coordinates you'd like repairs to be possible at. Then change the utilityType to either Elec for power repairs, or Water for water repairs.

You may copy and paste this line and paste it on a new line (don't forget the , at the end!!) to add more squares, and the script will cycle through and add them all.

It's worth noting that this template will apply your changes each time the save is loaded, so if you remove a square you set with the template using the in-game admin menu, the square will be re-enabled for repairs when you next load the game.

Functions you need to call

If you've messed with lua before then I'll try and keep this short and sweet. :) You may call RU_AddNewCoords(newCoordInfo) to add a new square, the newCoordInfo should be a table with the keys "X", "Y", "Z" and "utilityType"

You may also remove coords by calling RU_RemoveOldCoords(newCoordInfo), where newCoordInfo is a table with the keys "X", "Y" and "Z".

If you try and feed either function with invalid coordinates (the space is already taken for AddNewCoords, or the square isn't a repair square already for RemoveOldCoords), it will just print that it couldn't complete and then return.

Also worth noting that this method exists using the in-game admin tool functionality, so admins or players on debug mode in sp can remove any squares your code has set, or re-add squares your code has removed. Also you can NOT use the code to remove areas set by room type specifically by map-makers, they are set up in a different way using room names.

Method 3: Setting a room name (map-makers only)

In the TileZed building editor, select Building>Rooms to open up a window called "Rooms in building". When inside this window, add a new room type. You may call the name of the room whatever you like, the Internal name of the room must be set to either "RU_Elec" or "RU_Water", depending on which utility you'd like this room to be capable of repairing.

That's all you need to do to successfully set this room as one that players can repair in when using both Restore Utilities and your mod together :) Sorry this part of the guide is a bit short, I haven't touched TileZed in over a year so I was navigating through it trying to figure out how I did everything. Hopefully you know what you're doing enough to know what I mean, though :p
Last edited by Jackd44; Apr 30, 2024 @ 11:48pm
< >
Showing 1-4 of 4 comments
can you place the squares of the method 2 in zones from map mods?
Jackd44  [developer] Jul 2, 2024 @ 5:37am 
i'm almost certain it should work just fine, yeah
Hey @Jackd44! First, I have to say that this is an amazing mod. I am a map maker and I am working on a power plant for my town for the vanilla map. I have seen your mod and I have been brewing a bit about the restoring power bit of your mod. The idea I had was to place several power substations like the big one SE of LV (it is in cell 49x13) - I rebuild it in tileed so I can add terminals and additional buildings to replace this one. Once these are placed somewhere near each town, people would be able to do some repairs in the power station to re-enable it, then do some repair in the town region they would like to restore power to. In the power station there would also be a control monitor to check where power is active. Is this something doable in your opinion? I have not worked much with lua yet, but would like to give it a try. Perhaps something I could do with you together as an addon? Please let me know what you think :-)
Also, let me know if you would like to discuss on steam chat or in the PZ modding DC if you are in there.
Last edited by |wDe| Gernhart Reinholzen; Aug 18, 2024 @ 6:23am
Jackd44  [developer] Aug 18, 2024 @ 6:51am 
hi! sadly because of the way the mod is structured having repairs only fix areas of the map would be basically an entire new mod (that i do NOT have the brains to make :p)

also if you ever need to reach me for anything else you can always feel free to reach out and send a steam friend request, or just leave a comment here tbh. both are fine :)
< >
Showing 1-4 of 4 comments
Per page: 1530 50