Cities: Skylines

Cities: Skylines

Python Console
50 Comments
1yur 16 Apr, 2024 @ 8:15am 
@Strad
any plans for Cities Skylines 2?
eran0004 23 Mar, 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 10 Mar, 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] 10 Sep, 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 3 Sep, 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 3 Sep, 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 2 Sep, 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 1 Sep, 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 1 Sep, 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] 23 Aug, 2022 @ 10:38am 
@Thorium Unfortunately you can't get info about cargo at this moment.
☢️ W Y VΞ R Π 23 Aug, 2022 @ 12:18am 
@strad - Will this mod only interact with networks or can it also interact with plopped buildings. For example to monitor the amount of Cargo pushed to a Warehouse by a truck, and then monitor the amount pulled out into a truck for export. Other examples could be like monitoring units of cargo hauled by a moving freight train etc. etc.
Sir Sheikhs Pears 15 Dec, 2021 @ 5:50pm 
@IhmeHihhumi: RealGodzilla has done something like that on his map - tells us in detail about it on the MacSergey's Discord server in this thread: https://discord.com/channels/727463293253582967/731944724079968296/905565820573351986
Strad  [author] 13 Dec, 2021 @ 1:31pm 
@IhmeHihhuli Yes, it definitely possible to do that. You can get height data from the game and use them to compute the gradient. It requires to do a few trick so it is performant enough and the script doesn't take too much time to finish. If you are interested you can create an issue on the github page where we can talk about it more.
IhmeHihhuli ™ 13 Dec, 2021 @ 6:47am 
Judging by the GIF in the showcase image reel, with this mod you could auto-generate trees and resources to a map, am I right? Say for example, auto-generate trees to a map with a predetermined strength, programming the generation to happen on only certain terrain-gradient levels (i.e. place trees on low gradient hills only for example). I'd suppose the same could go with the resource painting as well.

I've dabbled some bit with Python and if the aforementioned is possible with this mod, this could probably revolutionize map making in some scenarios. We're talking about saving dozens of hours potentially. Really curious as to how well this mod could be utilized in that specific use-case. Thumbs up regardless! :hardhat:
Sasquatch 21 Nov, 2021 @ 6:22pm 
@Strad Yeah, I don't know any python. So I really wouldn't have a clue where to start.
Strad  [author] 21 Nov, 2021 @ 2:48am 
If you want to add transition curves, you probably need to rebuild all the roads, which is quite a hassle. But you can code a script that would do all that for you - it isn't included in the mod by default.

As for following the terrain - yes, there is an option for that.

Anyway, if you don't know coding it could be quite time consuming for you.
Sasquatch 20 Nov, 2021 @ 5:54am 
Looking at the wiki, I like the idea of being able to add transition curves to roads. Is that something that can be done to existing road, or does it need to be done when you build the road? Also, is it possible to tell it to build roads that follow terrain contour lines? My biggest aggravation with the game is building realistic mountain roads that follow the terrain and have sensible switchbacks.
Simuscape 12 Jul, 2021 @ 2:37pm 
@10SunBee , hahaha... I was thinking the very same....
10SunBee 12 Jun, 2021 @ 8:22pm 
I am afraid that I am not mathematically smart enough to use this mod lmao
Flesh Pound 6 Jun, 2021 @ 6:45am 
Wonderful!
Strad  [author] 24 May, 2021 @ 1:05pm 
Not for now. If you want to know a name of a specific road, build it with a road editor and then use clipboard tool to find its name.
You can add me on steam - I will be happy to answer all your questions :)
oliver 24 May, 2021 @ 8:46am 
Is there a way to iterate through all road types?
Victor 24 May, 2021 @ 12:50am 
OMG
Chief_Falkon 18 May, 2021 @ 8:51pm 
This is probably a bit too advanced for me today, but maybe one day... Definitely love the concept
Koesj 14 May, 2021 @ 2:51pm 
Insanely good mod, many thanks!
Indoctrinated 17 Apr, 2021 @ 1:01am 
I haven't strayed far from CPython or Cython, so I'll have to take a good read over the IronPython API.
Strad  [author] 15 Apr, 2021 @ 12:48am 
Unfortunately not all libraries work with the IronPython engine.
I am happy to help if you would have questions about the API or have problems with making it work.
Indoctrinated 15 Apr, 2021 @ 12:20am 
Definitely going to try this out. I've always wanted to simulate a more accurate grid in-game, but the documentation for the C# API is kinda garbage.

Would it be possible to use use packages like, say, Numba, Pandas, and NumPy? Because this could get insane using Dask for simulation.
Strad  [author] 31 Mar, 2021 @ 1:08am 
For now you can't change traffic lights. Unfortunately it is not a trivial task because of compatibility issues with TMPE
ehel 30 Mar, 2021 @ 1:59pm 
is posible got get a state of an object. I mena like a trafic light?
Woud be so cool to program them.
Or that i seen some peopel try do. A bridge thats open up for ship when they come near a bridge.
Sp3ctre18 11 Mar, 2021 @ 8:49pm 
U kidZ n ur coding n automation! Back in my day we did this stuff by hand, eyeballed, calculated, getting those tangencies and 12 unit lengths in!
Strad  [author] 11 Mar, 2021 @ 11:15am 
I've just released a new version that includes the scripts (see the description)
@r3fe Hopefully one day
eran0004 11 Mar, 2021 @ 9:46am 
@Deeheks I study civil engineering, so that statement is pretty accurate! The script should be included with the mod soon :)
r3fe 11 Mar, 2021 @ 4:45am 
Is there any plan to make this available on other platforms besides Windows? Because this is literally the coolest thing ever.
kuaman 10 Mar, 2021 @ 9:46pm 
Awesome...
cbudd 8 Mar, 2021 @ 9:39am 
Amazing. Makes me wanna try learning programming now
Deeheks 7 Mar, 2021 @ 12:16pm 
CIVILskylines when?
wow eran you're amazing.. could you share some scripts eventually? would love to try!
eran0004 7 Mar, 2021 @ 10:59am 
I'm using this mod to design realistic curves for my railroads and highways. I can do that with MoveIt as well, but then I would have to manually set the coordinates of each node, which takes a lot of time. With this mod I can automate the entire process and have it done within two seconds.
Strad  [author] 6 Mar, 2021 @ 1:51pm 
You are right that it is rather a mod for "placing assets", but not every idea how to do that can be expressed with your keyboard and mouse.
macluk 6 Mar, 2021 @ 1:39pm 
Is it a mod for modding that I still cannot see any details on here how to mod? Or is it just for placing assets, which i can do with my keyboard and a mouse? Because the impression after watching the video is that the latter is the case here.
matt 6 Mar, 2021 @ 12:14pm 
The only Python I'm interested in features John Cleese, Michael Palin and Terry Jones... and I've no idea what I'm doing, but good work anyway!:steamthumbsup:
98ColdDew 6 Mar, 2021 @ 7:35am 
Incredible ! ! !
Strad  [author] 6 Mar, 2021 @ 7:13am 
Unfortunately ironpython integrated with dotnet doesn't support python 3, at least not officially
iamdumdum1234 6 Mar, 2021 @ 5:16am 
Why did you chose Python 2 instead of 3?
It is just a question, this mod is very interesting.
Strad  [author] 5 Mar, 2021 @ 2:06pm 
Yep, it should be 2.7
There should be most of the basic functionality. About the external libraries - I don't know. I think it is possible.
There is a page about standard file imports:
https://github.com/Strdate/PythonConsole/wiki/Python-Imports
Ingenium 5 Mar, 2021 @ 1:04pm 
That is awesome! Thank you.

I have seen on the Github that it works with IronPython. So it is Python 2.7? And are all Python functionalities available and can we load additional packages (numpy, pyopt, whatever)?
74091796519793665 5 Mar, 2021 @ 11:49am 
Wish you good luck with this project. Looks very interesting.
LemonsterOG 5 Mar, 2021 @ 9:36am 
@Strad -- Thanks! Hopefully, it will save you some headaches with MacOS player comments.
Strad  [author] 5 Mar, 2021 @ 9:28am 
Ok I put the warning at the top
LemonsterOG 5 Mar, 2021 @ 9:21am 
Will this work with MacOS? If not, I suggest noting that boldly at the very top of the description.