Jump to content

sc4 cli tool  0.2.24

   (2 Reviews)

2 Screenshots

About This File

This upload contains my sc4 cli tool. While already available on GitHub, I decided to upload it on the STEX as well to give it a bit more visibility. I initially developed the tool for a proof of concept that savegames could be modified, but in the meantime it has grown into a general purpose modding tool that can be used for various modding tasks.

Documentation can be found on GitHub. The most important thing is that the tool can be used in two modes:

  • By default, when opening the binary,  it will launch in interactive mode. It will prompt you what you want to do, such as growifying a city, creating a new submenu, ... You can also drag & drop files - such as an .sc4 savegame for savegame operations - on the binary to perform operations on that file.
  • You can also use it as a cli tool, meaning you interact with it using commands. There are various commands available for modding tasks, such as tracking dependencies with
    sc4 plugins track

    plopping all lots in a folder with

    sc4 city plop

    or extracting the contents of a dbpf file with

    sc4 dbpf extract

    Run

    sc4 --help

    to get an overview of all available commands.

I plan to update the STEX upload only when there are significant changes. If you want all the latest features, I advice you to download it from GitHub instead.

IMPORTANT INFORMATION

As specified in the license, the tool is provided "as is", meaning that it is your own responsibility to have sufficient backups of any files you want to modify, especially when modifying savegames. I am not liable for any of the consequences if your files become corrupted due to a bug in the tool.


What's New 0.2.24   View Changelog


Released

File restored after site crash. Previous hosted version was 0.2.23. Version 0.2.24 contains no user-facing updates. See detailed changelog here.

  • Like 22
  • Thanks 1



User Feedback

Recommended Comments

6 hours ago, Kel9509 said:

This is an EXE file.  Can this at least be zipped?

Ah, thanks for noticing. I assumed the .exe was already compressed, but turns out the file size could be reduced to 30MB this way. I changed the upload to a .zip and uploaded a Linux version as well.

Share this comment


Link to comment
Share on other sites

I guess this tool is more for people who know how to code (and create mods) and know the inner workings of the game? I'm kind of stuck at creating a new submenu and don't really understand how to proceed at the "Item Order". Looked through the documentation readme page but I couldn't find out how to proceed at the item order step either. 

Share this comment


Link to comment
Share on other sites
2 minutes ago, SC4 gamer said:

I guess this tool is more for people who know how to code (and create mods) and know the inner workings of the game? I'm kind of stuck at creating a new submenu and don't really understand how to proceed at the "Item Order". Looked through the documentation readme page but I couldn't find out how to proceed at the item order step either. 

The item order determines where the submenu will exactly appear. You can enter any value between -2147483648 and 2147483647. The lower the number, the higher the button will appear in the menu.

Share this comment


Link to comment
Share on other sites

After trying around with the tool, I finally figured out how to create submenues, this is so insanely helpful to tidy up all those cluttered menues. Thank you so much for creating this tool!

Share this comment


Link to comment
Share on other sites

Hello, I'm sorry I have another question:

So far everything has worked very great, I created a lot of submenues for the mods I have installed. Now I haven't played in 3 weeks and I can't exactly remember which number I assigned each submenu to. What could / would happen if I accidentally assigned a submenu to the same number? And is there a way to see which item order I assigned the already existing ones to?

Share this comment


Link to comment
Share on other sites

With "number", I assume you mean the item order? In that case, nothing bad will happen. They will simply show up next to eachother in the menu.

If with "number" you mean the submenu id (but I doubt you mean this), then the submenu will override the other one. However, submenu ids are assigned at random, so if you haven't set them manually, you don't need to be afraid of this.

Share this comment


Link to comment
Share on other sites

Thank you for such an awesome tool.

One question, even though it doesn't effect anything. For some reason when I go to add items to a submenu and choose the destination of a submenu I created within Parks--->Sporting Fields--->"Golf" , I have 2 instances of the same menu (2xGolf). This hasn't happened to the other submenus I created and searching all the usual places I couldn't find a duplicate file (submenu-golf.dat) ...any ideas?

Thanks.

Share this comment


Link to comment
Share on other sites
On 10-2-2025 at 1:08 PM, Dono said:

Thank you for such an awesome tool.

One question, even though it doesn't effect anything. For some reason when I go to add items to a submenu and choose the destination of a submenu I created within Parks--->Sporting Fields--->"Golf" , I have 2 instances of the same menu (2xGolf). This hasn't happened to the other submenus I created and searching all the usual places I couldn't find a duplicate file (submenu-golf.dat) ...any ideas?

Thanks.

You probably have a duplicate menu item in your configuration. You can either remove it by running sc4 config edit in a command prompt. If you are not familiar with the command line, then you can also use version 0.2.17 that I just uploaded. When choosing the option to scan for submenus in your plugins folder, you now get the option to reset the configuration instead of adding to the configuration. That way your submenus get reset, but beware that only the submenus that you have in your plugins folder will remain available when adding lots to a submenu in that case!

  • Like 1

Share this comment


Link to comment
Share on other sites
9 hours ago, smf_16 said:

You probably have a duplicate menu item in your configuration. You can either remove it by running sc4 config edit in a command prompt. If you are not familiar with the command line, then you can also use version 0.2.17 that I just uploaded. When choosing the option to scan for submenus in your plugins folder, you now get the option to reset the configuration instead of adding to the configuration. That way your submenus get reset, but beware that only the submenus that you have in your plugins folder will remain available when adding lots to a submenu in that case!

Thanks for the new Cli add-on. Can I answer No to the "Plugins" folder scan and then take the option to search a file I designate, such as just scan the Submenu folder in Plugins? Or does it need to also find the "submenu_patch.dat" files associated to the lots added to each submenu...as I left mine in each plugin folder I added to a submenu.

Only asking as I'm 33min in on the Plugin search lol. 

*** Got it to work but decided to take the risk and just scan the "submenu" folder as the Plugins scan got to 3hrs+, I tried it on another PC I have and it did the same...just kept searching. Assuming it's just because of the size size of our plugin folders these days.

Thanks for your continued awesome work!!! 


  Edited by Dono  

Share this comment


Link to comment
Share on other sites

As you noticed, you can indeed just specify the folder with the submenus instead of your entire plugins folder if you know that it's the only folder with the submenus (the patches are not needed for this).

Scanning all your plugins should not take longer than a minute or so, dependening on whether you have a HDD or an SSD, so I suspect it has choked over one of your plugins. It would be nice if you were able to hunt down what the plugin is it chokes over so I can verify what goes wrong.

Share this comment


Link to comment
Share on other sites
6 hours ago, smf_16 said:

 It would be nice if you were able to hunt down what the plugin is it chokes over so I can verify what goes wrong.

Being able to scan the submenu folder fixed my problem, but if it helps you I'll have a crack after work to see if I can find what one it is and I'll let you know 😊

  • Like 1

Share this comment


Link to comment
Share on other sites
7 hours ago, Dono said:

Being able to scan the submenu folder fixed my problem, but if it helps you I'll have a crack after work to see if I can find what one it is and I'll let you know 😊

Ok, took a while but it was the Dependency "North American Freight Cars" by Angry Mozart. Unfortunately, this dependency has 783 folders and 12018 files, the weird thing is I scanned the first 14 folders that start with a number and it didn't hang, I then scanned the second 16 folders and it hung for a moment then worked...but when I put them back in the original folder as a group it hung again. Anyway good luck *:)!!

Share this comment


Link to comment
Share on other sites

Hello @smf_16 , would it be possible to add a step to the creation of a submenu: Allow the choice of: entering the ID or auto-generation as you currently do.? Before entering the name, or after ;-)  This would avoid having to go back to Reader, when creating a package of SMen, agreed in advance by ..a team ..! .. Thanks!

Share this comment


Link to comment
Share on other sites

Yes, that should be possible. I'm currently a little tight on free time though, so feel free to ping me again in a month or so if I haven't implemented it by then!

  • Thanks 1

Share this comment


Link to comment
Share on other sites

Hi, could someone point me in the right direction to the location the sc4cli tool gets the path from in Windows 11 if any. I can still add items to a submenu but I can't create a new submenu as it says the directory path is incorrect, was hoping to change it if it has a physical form somewhere.

I used to have onedrive but since I turned it off the file path has dropped the "onedrive" bit. I have everything in the correct place but it's calling on the old path but I don't know where from. Hopefully I'm overlooking something silly.

Thank you.

Error.jpg

Share this comment


Link to comment
Share on other sites

@Dono The problem is that your configured plugins folder no longer exists (it still uses the OneDrive version), so the tool can't save the file.

If you download version 0.2.20 (which I just released), then this issue should be solved and the tool will automatically scan for your new plugins folder if it detects the configured folder no longer exists. You now also have the option when running the tool to open and edit the configuration file yourself.

  • Like 1

Share this comment


Link to comment
Share on other sites

Hi @smf_16, I was trying to add lots to the submenu Water Transit/Boats, Ships and Watercraft (0xDD5DC0E7), but it was not listed. Does your feature read the existing submenus and keep up with updates of memo's list or is it hardcoded?

Share this comment


Link to comment
Share on other sites

I think that memo's list is hardcoded, so I would have to update it. However, the tool also has a command that scans your plugins folder for any submenus and then makes them available for use. It should discover the additional submenus as long as they are somewhere in your plugins folder, so you should be able to use that until I've had the possibility to update the hardcoded list.

  • Thanks 1

Share this comment


Link to comment
Share on other sites

Hi @smf_16 .. I'm trying various ways to create submenus, making mistakes, deleting files from "Plugins\", and starting over. So I ran the command `[scan plugins for submenus]`, pressing "y" twice, to get SC4-CLI to compile an updated list of submenus in my directory. I don't know how long this function should run to analyze the Plugins folder. .. slash-pipe-slash ... 40 minutes is still a long time! *;) .. JI closed sc4-cli and restarted it, but I still see some submenus that shouldn't appear anymore. I found the config.yaml file and saw that it was accumulating several "entries/tests" I had run. It hadn't rewritten anything after the scan. How/what can I do to make the analysis work? Thanks in advance.

Share this comment


Link to comment
Share on other sites

Hmmm. For starters, it should never take longer than a minute or 2, even for plugin folders containing gigabytes worth of files. First of all, I would make sure to have the latest version, because I remember @nos.17 having a similar problem as well, which was actually a bug that I fixed afterwards. If that doesn't solve the issue, I think there might be a circular reference somewhere, where a submenu's children contains one of its parents. That can mess up the tree-structure that is being built up while scanning and can result in an infinite loop.

Share this comment


Link to comment
Share on other sites

Sign In or register to comment...

To comment in reply, you must be a community member

Sign In  

Already have an account? Sign in here.

Sign In Now

Create an Account  

Sign up to join our friendly community. It's easy!  

Register a New Account

×

Thank You for the Continued Support!

Simtropolis depends on donations to fund site maintenance costs.
Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

Make a Donation, Get a Gift!

Expand your city with the best from the Simtropolis Exchange.
Make a Donation and get one or all three discs today!

STEX Collections

By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

Each donation helps keep Simtropolis online, open and free!

Thank you for reading and enjoy the site!

More About STEX Collections