-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Scripted Chat Commands #675
feat: Scripted Chat Commands #675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good PR, nice job. Although i was thinking that we were avoiding exposing DdonGameServer and such directly in these scripts, using LibDdon as a proxy instead
|
||
public class ChatCommand : IChatCommand | ||
{ | ||
public override AccountStateType AccountState => AccountStateType.Admin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh
Arrowgene.Ddon.Shared/Files/Assets/scripts/chat_commands/motherload.csx
Outdated
Show resolved
Hide resolved
Ideally we would probably want that but some things definitely need some refactoring to support that. This was mostly just a migrate what's there change. Almost everything is built around accessing directly through our server object. It's hard to get around that pattern unfortunately. I should probably take some time to access settings through LibDdon. Not sure what to do about the objects that require the server though. |
Arrowgene.Ddon.Shared/Files/Assets/scripts/chat_commands/givepowerfulitems.csx
Outdated
Show resolved
Hide resolved
|
||
public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses) | ||
{ | ||
var handler = new ChatCommandHandler(server); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that this command is used often, but do we need to be careful invoking a new copy of this object every time? Not sure if script stuff changes this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's wasteful from a resource perspective, but also this is a debug command, so I am not super worried about it. I was thinking making LibDdon can make a cached set or something? One thing I am having trouble with is that since I made it such that implementation is shared across the Server and DdonGameServer projects, I am having trouble to get the server into the area where the constructor is passed. I can take another look or see if we can do something in the library instead.
} | ||
|
||
sb.Append($"Weather:{server.WeatherManager.GetWeather()} ({weatherIndex}) "); | ||
sb.Append($"{remainingSeconds}/{server.WeatherManager.WeatherLoopList[weatherIndex].TimeSec} seconds"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The moon information got added to this command a little bit ago, should be included here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share which information you want? This is just a copy+paste of the command that existed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused, it was apparently this commit that somehow ended up in my area ranks branch. 949a6d7
9e098a7
to
da879c2
Compare
- Created a new scripting module to handle chat commands. - Migrated all existing chat commands to scripted chat commands. - Updated the help command to only list commands which fall within the AccountState limitations. - Updated many chat commands to have an account state of type Admin. - Added a new settings file ChatCommands.csx. - Support hotloading of modifying or adding new chat commands.
- Rename motherload.csx to motherlode.csx - Added two new helper methods to LibDdon - LibDdon.GetSetting<t>(scriptName, key); - LibDdon.GetHandler<t>();
da879c2
to
3aedd6a
Compare
Checklist:
develop
branch