Debug Function

So I have been away from the game for a while, and away from Mafia scripting as well. But in trying to get reacclimated with everything (it has mostly all changed completely in being gone for over a year) I noticed a common routine in a lot of threads here. People reporting bugs, but not giving enough of the session information. So I have a concept idea for a function for scripters to tag into their apps.

Basically it would work like the notify command (notify "xyz_123"). But rather than sending a generic "User ____ is using ______" message, it would send useful data.
The data could range from error logs (not mafia app errors, but errors in scripts) to session results (meat/items gained, items used, buffs in use, etc.). This type of data could be used for analysis of game mechanics (session results) as well as refining scripts.

I am not entirely sure if this type of functionality is currently available in kolMafia's current setup though. I don't think there are easy ways to get_script_error() or get_session_results() But like i said, I have been gone for a while, and the wiki seems somewhat incomplete.

The data would be sent via kmail to the designated author or debug account, whatever, and could be sent in some sort of CSV type format so data could easily be sorted and viewed in something like excel.

Thoughts, comments, ideas? This is a rather incomplete thought, but I wanted to get it out there to see if something already existed or if it is even possible currently. So here it is, do what you will with it.
 

Grotfang

Developer
I'm not entirely sure what sort of bugs you are referring to here. Bugs that stop the script from working will simply make it fail to compile. How would you spot the difference between a user error, a typo, or an outdated version of mafia, in that instance?

If you are referring to a bug, as in, the script behaving in a way that is unexpected... well, how would the script now that it is behaving in an unexpected manner? As far as it is aware, it is doing everything as it should. A script is simply a series of instructions, after all. Author error is... well... not the script's fault.

A bug that truly screws mafia over already produces a debug log... so clearly you aren't referring to that. I'm confused as to when this sort of function would be useful.
 

DaMaster0

Member
Well, I made something that might help you. If you change your scripts to compose a string[int] map while it's running, you can use this function:

boolean send_error(string who, string[int] log, string scriptname)
boolean send_error(string who, string[int] log)


If you use the second one the script will make your scriptname unnamed script. But anyways, if your script was composing the string[int] map of all it's actions, and it encounters an error, this function will send the map to you. This won't be useful at all if your script has an error that prevents it from compiling. And I don't know any way to get the session results, so that means your script has to make it's own. This might not be what you're looking for, but tell me if it helps!

I have tested it, and I think I like my own work so much I'll use it in the future! Kere's what my kmail looked like:

Debug map returned from unnamed script. Each new entry in the map is preceded by <#> so you can easily search for a specific entry. <1> test <2> test2
 

Attachments

  • senderror.ash
    3.4 KB · Views: 30
That basically was the idea. Having thought it through more, it is a flawed idea in this application. If it's broke, it won't work anyway. And if it's good, then it's unnecessary. Just getting back into the groove of things, stupid questions are inevitable :p
 

Grotfang

Developer
Am I right in thinking that this simply kmails each line you add to the map, essentially like sticking a load of print()s in and getting someone to post their CLI output?
 
Am I right in thinking that this simply kmails each line you add to the map, essentially like sticking a load of print()s in and getting someone to post their CLI output?
That was one of the thoughts, as a way to gather data on game mechanics. Or be able to compare scripted results with that of manual playing (ie. "Using xxxxx.ash increases meat/item/whatever 76% with 50% less work")
 
Top