Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Virtual gardener
staff: administrator
Original Poster
#1 Old 19th Sep 2019 at 5:22 PM
Default Best methods on debugging script mods
Hi everyone!

Scripting for ts3 can be a pain. We all know this But what's your preferred way of debugging your script mods? Or what other mods would really help this progress?

Personally, I find using just the good old "I am working!" Notifications work. However, when you're first setting up everything there's a 50% chance that it won't even run that notification (or the script) if you have any additional code written in the script. Moments like these made me wish we had something that would run against EA's code to see if it would function in-game before booting up the game.

Any thoughts?
Advertisement
Space Pony
#2 Old 19th Sep 2019 at 7:01 PM Last edited by gamefreak130 : 20th Sep 2019 at 5:26 PM.
Quote: Originally posted by Lyralei
Hi everyone!

Scripting for ts3 can be a pain. We all know this But what's your preferred way of debugging your script mods? Or what other mods would really help this progress?

Personally, I find using just the good old "I am working!" Notifications work. However, when you're first setting up everything there's a 50% chance that it won't even run that notification (or the script) if you have any additional code written in the script. Moments like these made me wish we had something that would run against EA's code to see if it would function in-game before booting up the game.

Any thoughts?


If I'm debugging methods that run on preload, I usually place an alarm to a debug function that will call a notification after a few sim-minutes -- well after everything is properly loaded. This notification can reference some data that you modified in preload to make sure the method ran correctly; in your case, you may even consider creating some kind of temporary static debug variable, trying to modify its value on preload, and checking afterwards. If it's somewhere in which ALARMS don't work (i.e. on application startup), you can always place a debug OnWorldLoadFinishedEventHandler to call the alarm from.

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Space Pony
#3 Old 20th Sep 2019 at 2:54 PM
Here are a few steps i take sometimes (in addition to gamefreaks suggestion)
1. When possible seperate pure script logic from game logic and run the pure logic in an Console Program.
2. The use good old Exception Error Screen window implementation
Code:
		public static bool ShowException(Exception exception)
		{
			try
			{
				return ((IScriptErrorWindow)AppDomain.CurrentDomain.GetData("ScriptErrorWindow")).DisplayScriptError(null, exception);
			}
			catch
			{
				WriteLog(exception);
				return true;
			}
		}
		public static bool WriteLog(Exception exception)
		{
			try
			{
				new ScriptError(null, exception, 0).WriteMiniScriptError();
				return true;
			}
			catch
			{
				return false;
			}
		}
and catch Exceptions with it Note: this doesnt seem to work sometimes with UI errors when the UI modification is already running (you will still get the error message but in an text file rather than ingame)
3.Encapsulate code and run each method one by one to see which one throws te error (this really is just what gamefreak suggestet if i think about it)
4. hmm theres probably more but i cant recall right now
Virtual gardener
staff: administrator
Original Poster
#4 Old 22nd Sep 2019 at 10:32 AM
Thanks for sharing! It really just seems to come down to regular debugging no matter the language.

Quote:
1. When possible seperate pure script logic from game logic and run the pure logic in an Console Program.


I like this one, mainly because you don't hear this that often... and I honestly forgot that that's obviously possible.

The exception stuff is also not a bad idea. (might have stolen it Cmar used it too IIRC in her code) I noticed that some script modders seem to do this through a notification, which is also a way of doing it of course, but having everything in a xml file to look at later is personally more my preferences.

I do remember ever using this mod: http://modthesims.info/d/384682/ena...or-updated.html
Although who knows if that still works It does however trigger a crap ton of those windows if you have mods. And it's all individual so I've ended up having to close 100 of these screens :P
Space Pony
#5 Old 22nd Sep 2019 at 11:58 AM
Quote: Originally posted by Lyralei

The exception stuff is also not a bad idea. (might have stolen it Cmar used it too IIRC in her code) I noticed that some script modders seem to do this through a notification, which is also a way of doing it of course, but having everything in a xml file to look at later is personally more my preferences.

I do remember ever using this mod: http://modthesims.info/d/384682/ena...or-updated.html
Although who knows if that still works It does however trigger a crap ton of those windows if you have mods. And it's all individual so I've ended up having to close 100 of these screens :P


Well i never wrote that i came up with those ideas originally, i got the code from this tutorial http://www.modthesims.info/showthread.php?t=491875 :p

E: oh when you use the code you get the exact blue screenish error window like in the link you posted, but you can also get the xml depending on your implementation and the nature of the error/ its enviromental appearance(see ui)
Virtual gardener
staff: administrator
Original Poster
#6 Old 28th Sep 2019 at 10:43 AM
The game has its own XML error debugging functions so that by itself is helpful as well (Even though it requires some digging) but yeah!

Also, in case you guys wanted to know, the blue screenie error thingie from this download: http://modthesims.info/d/384682/ena...or-updated.html
It still works, so if you want to give it a try, totally go for it!
Back to top