Prison Architect

Prison Architect

Not enough ratings
Script Debugger: how to find bugging objects
By murgh
Do you have the Script Debugger window popping up when playing a game, but no idea what's bugging you?
This little guide will explain how to find out what's wrong with one of your mods.
   
Award
Favorite
Favorited
Unfavorite
Script Debugger window with no errors...
Sometimes a scripted mod can have a bug which will produce an error. Unfortunately the Script Debugger window is bugged by itself, leading to confusions. What's going on here?

When a script error pops up, it will open the Script Debugger window. But this window won't open on the bugging object. Instead, it will open on some random scripted object on the map.

So what you will get is a window with no error messages, as shown in the screenshot.
The example opened the StreetManager object, but as you can see this object is perfectly fine. So the bugging object is something completely different...
Finding the bugged object
What you have to do is press the bottom left button of this window. A list will appear with all scripted objects on your map.

This can be a real pain if you have a large map with many scripted objects. The example shows only a few, but this list can become HUGE.

Click on an item in the list to open the Script Debugger for that object. No errors? Click the button again and check the next object from the list... Until you finally find the error.
Error found!
If you are lucky, you will find the object with the bug sooner or later. This screenshot shows the bugging object. As you can see, the error wasn't in the StreetManager object, but in the CarFrontLesson object, on line 86 of that script to be exact...
When you have many mods enabled, this will be a big problem. You think at first that the StreetManager was bugging you, since it opens on that object. But that script window was empty, so the mod which has the StreetManager in it had NOTHING to do with the actual bug. It has become a Russian Roulette since PA update 8, when the devs fkd up the Script Debugger...
Debug.txt - another way to find script errors
Another way to find script errors is by looking into the debug.txt file which is made by the game. To see what's going on in this file, open the game menu and go to the Options screen, where you click on Open Save Folder.



The Windows Explorer window will open and there you have debug.txt
Quit the game once you've opened this window.



Debug.txt will be constantly updated by the game, so scroll to the bottom of the file and there you will find the error soon enough.


With a bit of luck the errors will show up just after a bugged script has been run by the game, so you should be able to know which script was bugging you. Unfortunately, the error in this example remains a mystery, since there was no script directly above it... instead the game just saved the preferences.txt file on the moment this error occurred. Sometimes you can guess which kind of object it was, depending on the kind of error you see...
Conclusion
Script errors have become very confusing.

The Script Debugger window pops up, and the only thing you saw at first was 'StreetManager', so you would think that the mod with that object has a bug.

Next, you'd probably start complaining at that mods' comments section that this mod has bugs and opens the debugger. But the author of that mod has nothing to do with the bug you are experiencing.

In fact, it can be a completely different mod, and it usually IS a completely different mod which is bugging you.

So before you start posting your complaints at a mods page, you should be sure that you have actually pinpointed that particular mod to be problematic. Because in 99% of the cases it's NOT that mod which gave you problems.
12 Comments
知忆 29 Nov, 2020 @ 7:24am 
666
murgh  [author] 28 Jun, 2018 @ 3:37pm 
btw there is a lot of activity on the bugtracker, looks like a serious crash bug bash going on.
murgh  [author] 28 Jun, 2018 @ 3:10pm 
They never changed support for that. I just had some serious brain damage to get a grip on how the fuck that one works... But I made flyby firemen with my chinooks as well, so I knew some things are possible :)
leftbehind 28 Jun, 2018 @ 3:09pm 
Awesome, thanks!

BTW, it was one of your mods that made me consider getting back in to PA modding (the stuff with the fire hoses - that was a blocker for me back in 2015 and I think the final straw that made me quit modding at that time).
leftbehind 28 Jun, 2018 @ 3:00pm 
Well, first thing I'll want to do is complete the guide I started on github to get all the latest infos added to it: https://github.com/aubergine10/Prison-Architect-API/wiki/YourModFolder

I'll reinstall game over weekend and take a look - will take me a while to get back up to speed. Is it possible to download old versions of the game? One of the things I want to do is upload some of the game's own resources to the github so I can see what's changed over the past few years - last files I uploaded were from version 1.1 (might have missed a few): https://github.com/aubergine10/Prison-Architect-API/tree/master/main/data
murgh  [author] 28 Jun, 2018 @ 11:38am 
It's always good to have inventive modders around, so why not :)

Modding is however difficult, so you might need to hurt your brain to find different approaches to deal with the thing you want to achieve. But I guess my workshop shows that there is a lot possible, even without full modding capabilities.

Leander did his best to get the stuff enabled which I suggested, but getting the modded staff to do what it does now took quite some hassle and testing. And it's still not 100% optimal, but making it to about 95% I'd say we have to live with it and deal with some small things anyway like usual. It shows how difficult the system behind all this really is. There are many things which still need to be made fully moddable though.

btw I've used your guides a lot, can't do without. If those guides weren't there, I probably would never have started modding. They are of very high value!
leftbehind 28 Jun, 2018 @ 9:30am 
I used to do modding for PA back in the alpha days but gave up due to all the bugs and the attitude of the devs towards said bugs - has it got any better? Is it worth me returning to modding?
murgh  [author] 6 Jan, 2018 @ 4:03pm 
This issue has been solved in Update 13, where the Script Debugger will open with the bugging object as it sould. In debug.txt it will now also tell the name of the script to make things easier to track down.

So the bug described is only happening in Update 8-12. Other builds are not affected.
BurgerWithButter 11 Oct, 2017 @ 9:16pm 
When i get a script error, i just click and drag it to corner of my screen until i only see the corner of the error.