Cities: Skylines

Cities: Skylines

118 ratings
Python Console
2
   
Award
Favorite
Favorited
Unfavorite
Mod
File Size
Posted
Updated
11.646 MB
Mar 5, 2021 @ 8:31am
Oct 8, 2021 @ 6:52am
11 Change Notes ( view )

Subscribe to download
Python Console

Description
Warning: For now the mod is Windows only

Are you interested in building super realistic cities or procedural map generation? Do you sometimes feel that the standard tools the game provides you to build roads, buildings, trees and stuff are just not good enough? This mod enables you to engineer your cities with precision and scale never seen before using python. Just hit ALT+S and console window appears. With it you can programmatically interact with the game.

So far, this mod allows you to:

  • Build and move game objects (such as roads, buildings, props, etc.)
  • Set natural resources
  • and more

How do I use this mod?

You can watch the tutorial video above or follow the written tutorial in-game. You can also find some resources on wiki[github.com].

Clipboard tool

Press ALT+A to activate the clipboard tool. Hold CTRL to select multiple objects or SHIFT to freely select any point on the map. These points are then accessible in your script as variables. See more on wiki[github.com].

Smooth road and track curves

To build smooth curves from examples above use the curveapp.py script, that is located in the examples subdirectory of the default script workspace. Learn more on wiki[github.com] (Big thanks to @eran0004 for creating that script!)

Standard library included

This mod ships with PyPy[www.pypy.org] standard library, so you can use modules like random without any further configuration.

Important note!

This mod is still in BETA. There are no known severe bugs, but you always use the mod on your own risk. Please report any odd behavior in the discussion section.

Source code

Github repository[github.com]


Address: bc1qvma38p2fcgle9z0w3dehljjt303r4q2qg89nqy

Please leave any feedback below!
50 Comments
1yur Apr 16, 2024 @ 8:15am 
@Strad
any plans for Cities Skylines 2?
eran0004 Mar 23, 2023 @ 10:50am 
@Pistro It's caused by calling a function before it has been defined. In the original code, the curve function is defined starting on line 29, while the call is made at the end of the script on line 116.
Pistro Mar 10, 2023 @ 9:44am 
Hi, I'm getting "Error: name 'curve' is not defined (script: line 1)" when executing the curveapp.py script. What could be the cause?
Strad  [author] Sep 10, 2022 @ 1:19pm 
@Theodoroid Send me a friend request or create an issue on github - steam comments aren't a convenient place for such a technical discussion

Why do you need to debug the python server in the first place? The IronPython engine does not work? :)
Theodoroid Sep 3, 2022 @ 4:55am 
[continued 4]
Alt+S brings up the ingame console, but it does not appear to be attached to the python server (pressing F5 on priint("Hello World!") has no effect. Should it? The wiki suggests that the in game component " will automatically connect to it after you open the Python Console dialog window." Should the ingame console be usable?

In VC22, I'm not yet able to execute code and have it affect the game state. The edittor isn't recognizing game symbols. What should I be using as the Python environment? Am I on the right track?
Theodoroid Sep 3, 2022 @ 4:39am 
[continued 3]

Looking at the PC source code suggests it's using a vanilla TCP connection. As VSC doesn't offer that option (ssh is supported), I've installed VS22. Manually launching SkylinesRemotePythonDotnet.exe, and then, in VS22, Debug->Attach To Process produces several lines of output of the form '

SkylinesRemotePythonDotnet.exe' (CLR v4.0.30319: SkylinesRemotePythonDotnet.exe): Loaded 'C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll' . Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

In C:S I've enabled all the options except "execute scripts synchronously"
Theodoroid Sep 2, 2022 @ 10:23am 
[continued 2]

On further reflection, I think I understand why my prior attempts failed: what I need to do is establish a connection with SkylinesRemotePythonDotnet.exe running as a "remote" sever, not as a local interpreter. I found multiple tutorials on how to do this in VSC, so it seems probable that it's possible to do it with Python Console. However, I do not know what port to use, if there is an authentication token, etc. Any clarification you could provide would be most appreciated.
Theodoroid Sep 1, 2022 @ 5:24am 
[continued]

Am I correct in assuming SkylinesRemotePythonDotnet.exe is the Python interpreter? VSC (and PyCharm) both complain with similar messages (e.g., VSC's says, "An invalid Python interpreter is selected"). I tried making a copy named python.exe. in the same directory, but it too was rejected. To ensure I understood the configuration process correctly, I also installed IronPython and had no trouble VCS to use it.

I'm now at a loss on how to proceed. Would you please elaborate on how to configure VSC (preferably or VS otherwise) to work with your marvelous creation?
Theodoroid Sep 1, 2022 @ 5:23am 
@Strad first, kudo's on creating an amazingly powerful and useful tool for the programmatically inclined!

The wiki mentions "You can run and debug the extarnal Python application directly from Visual Studio" and "you can start the server in VS." My efforts to do so have thus far proven futile and I realize the fault may be my own because my attempts (thus far) have been with VSC (with the MS Python Tools installed as recommended on the IronPython page) rather than VS proper.
[continued]
Strad  [author] Aug 23, 2022 @ 10:38am 
@Thorium Unfortunately you can't get info about cargo at this moment.