Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

[Idea] Debugging cs scripts

Open TyraVex opened this issue 3 years ago • 4 comments
trafficstars

Prerequisites

Console Client Version

Latest

Describe your problem

Make mcc give the line and column of the error when the compiler fails please :) It would be a great feature to save time...

Suggest a possible solution

^

Attach screenshot here (If applicable)

No response

Minecraft Version

All

Device

Desktop

Operating System

Linux

TyraVex avatar Dec 28 '21 22:12 TyraVex

Yes, would be very nice sometimes, so maybe someone could include it in the CSharpRunner class and so on. I don't really know anything about it, but maybe this link could help? 'https://docs.microsoft.com/de-de/dotnet/api/system.codedom.compiler.compilererror?view=dotnet-plat-ext-6.0'

Edit: Maybe just changing result.Errors[0].ErrorText in Line 120 to $"{result.Errors[0].Line};{result. Errors[0].Column}: {result.Errors[0].ErrorText}" would be enough?

Edit 2: I also think, MCC often doesn't accept scripts even if their is just a warning like 'XY is declared, but it's value is never used' in them. Maybe result.Errors[0].IsWarning could also be used and displayed another way instead of canceling the script.

xXjojaXx avatar Dec 29 '21 17:12 xXjojaXx

Hello,

I would highly recommend using an actual IDE like Visual Studio for developing a ChatBot or any advanced script. You can do so by downloading the whole project and opening it in your IDE, then adding the ChatBot along with the others. Once done, you can auto-load it on login by adding a line in McClient.cs: https://github.com/MCCTeam/Minecraft-Console-Client/blob/25248025c21cfd1c11c86deb90c029080fdc937e/MinecraftClient/McClient.cs#L217-L218

If you do this, you'll benefit from all the debugging capabilities of your IDE. Once done developing your ChatBot, you can wrap it into a C# MCC script and load it conventiently with /script.

ORelio avatar Jan 01 '22 22:01 ORelio

Hello,

I would highly recommend using an actual IDE like Visual Studio for developing a ChatBot or any advanced script. You can do so by downloading the whole project and opening it in your IDE, then adding the ChatBot along with the others. Once done, you can auto-load it on login by adding a line in McClient.cs:

https://github.com/MCCTeam/Minecraft-Console-Client/blob/25248025c21cfd1c11c86deb90c029080fdc937e/MinecraftClient/McClient.cs#L217-L218

If you do this, you'll benefit from all the debugging capabilities of your IDE. Once done developing your ChatBot, you can wrap it into a C# MCC script and load it conventiently with /script.

Of cause using an IDE for advanced scripting is highly recommended, but I think it's worth making such a little change to make little changes in the production/runtime environment on servers etc. a whole lot easier. It would also help at debugging errors that only occur sometimes and weren't showing up in development because the environment the bot is running in can change for example if you share chatbots with others using mcc or if the computer you're developing your scripts on has another os and so on than the conputer or server it's running on in production/final use case.

This means it would be very nice if you could reconsider including more specific debugging output into MCC. Thank you very much for reading.

xXjojaXx avatar Jan 02 '22 14:01 xXjojaXx

Of course any improvement is welcome! I just don't really have enough time to work on this myself. Feel free to send a PR 👍

ORelio avatar Jan 21 '22 21:01 ORelio

Implemented in 78f9c3580009c137ec3896173dd4799dfd3a7110

milutinke avatar Oct 20 '22 13:10 milutinke

I didn't even realize i implemented a feature request 🤣

breadbyte avatar Oct 20 '22 13:10 breadbyte

I didn't even realize i implemented a feature request 🤣

I think I've mentioned it once to you. Maybe you forgot it xD

milutinke avatar Oct 20 '22 14:10 milutinke