Skip to content
Permalink
Browse files

[Script Commands] Display whether commands are disabled due to script…

… or setting

- The bot now has a modScripting.IsScriptEnabled() function to handle
  checking if a script is enabled, rather than having repeated code to
  access the relevant SSC.GetSettingsEntry every time. Now uses the SSC
  directly instead of the module's CodeObject's GetSettingsEntry.

- .scripts, .scriptdetail, .initperf, .enable, and .disable:
  These commands' output has been made slightly more consistent.
  Script names are quoted, and when relevant, script names appear
  with the text "(disabled)".
  The .scripts command still uses parentheses to indicate disabled scripts.

- .scriptdetail, .initperf, .enable, and .disable:
  These commands may now search for scripts by the start of the input
  given. For example, "uni" will find a script named "UnicodeMacros".
  They say no script was found if there are multiple choices.

- .help:
  This command (and the Command Manager) will now list the script in the
  requirement text. It will have the text "(disabled)" if the script is.

  This command will now have the text "(disabled)" after the name if
  the command itself is disabled.

  Both the script and command may be disabled.

- .helpattr and .helprank:
  These commands now do not list commands that are disabled or commands
  owned by a script that is disabled.
  • Loading branch information...
nmbook committed Nov 28, 2017
1 parent a40dcae commit 2f9732d9f99d343269e0e941e57c020bc24532f1
Showing with 192 additions and 129 deletions.
  1. +21 −12 trunk/clsCommandDocObj.cls
  2. +14 −12 trunk/modCommandsAdmin.bas
  3. +99 −68 trunk/modCommandsInfo.bas
  4. +58 −37 trunk/modScripting.bas
@@ -1146,25 +1146,33 @@ End Function

Private Function GetRequirementsString(Optional bShort As Boolean = False)

Dim retVal As String
Dim retVal As String
Dim DetailReq As String
Dim StateStr As String

If (m_command_node Is Nothing) Then
Exit Function
End If

retVal = vbNullString
StateStr = vbNullString

If bShort Then
DetailReq = "Requires"
Else
DetailReq = "Command requires"
End If

If (m_command_node Is Nothing) Then
Exit Function

If (LenB(Me.Owner) > 0) Then
If (modScripting.IsScriptEnabled(Me.Owner) = False) Then StateStr = " (disabled)"
retVal = StringFormat("From script ""{0}""{1}. ", Me.Owner, StateStr)
If (Not bShort) Then retVal = retVal & vbCrLf
End If

If (Me.RequiredRank <> -1) Or (Len(Me.RequiredFlags) > 0) Then
If (Me.RequiredRank > -1) Or (Len(Me.RequiredFlags) > 0) Then
'// available outside the console
retVal = vbNullString

'// add access requirements if necessary
If (Me.RequiredRank <> -1) Then
If (Me.RequiredRank > -1) Then
retVal = StringFormat("{0}{2} rank {1}", retVal, Me.RequiredRank, DetailReq)
If (Len(Me.RequiredFlags) = 0) Then
retVal = StringFormat("{0}.", retVal)
@@ -1173,7 +1181,7 @@ Private Function GetRequirementsString(Optional bShort As Boolean = False)

'// add flag requirements, if necessary, taking into account the existinance of an access requirements
If (Len(Me.RequiredFlags) <> 0) Then
If (Me.RequiredRank <> -1) Then
If (Me.RequiredRank > -1) Then
retVal = StringFormat("{0} or one of the following flags: {1}.", retVal, Me.RequiredFlags)
Else
retVal = StringFormat("{0}{2} one of the following flags: {1}.", retVal, Me.RequiredFlags, DetailReq)
@@ -1182,9 +1190,10 @@ Private Function GetRequirementsString(Optional bShort As Boolean = False)

Else
'// console only, lets show the generic blurb
retVal = "Only available to the console."
If (Not bShort) Then
retVal = "Command is only available to the console. Set a rank or flag requirement to make this command available to external sources."
If (bShort) Then
retVal = StringFormat("{0}Only available to the console.", retVal)
Else
retVal = StringFormat("{0}Command is only available to the console. Set a rank or flag requirement to make this command available to external sources.", retVal)
End If
End If

@@ -137,23 +137,24 @@ Public Sub OnDisable(Command As clsCommandObj)
Dim mnu As clsMenuObj

If modScripting.GetScriptSystemDisabled() Then
Command.Respond "Error: Scripts are globally disabled via the override."
Command.Respond "Error: Scripts are globally disabled."
Exit Sub
End If

If (Command.IsValid) Then
Set Module = modScripting.GetModuleByName(Command.Argument("Script"))
Name = Command.Argument("Script")
Set Module = modScripting.GetModuleByName(Name, True)
If (Module Is Nothing) Then
Command.Respond "Error: Could not find specified script."
Command.Respond StringFormat("Error: Could not find the script ""{0}"".", Name)
Else
Name = modScripting.GetScriptName(Module.Name)
If (StrComp(SharedScriptSupport.GetSettingsEntry("Enabled", Name), "False", vbTextCompare) = 0) Then
Command.Respond Name & " is already disabled."
If (modScripting.IsScriptEnabled(Name) = False) Then
Command.Respond StringFormat("Error: Script ""{0}"" is already disabled.", Name)
Else
RunInSingle Module, "Event_Close"
SharedScriptSupport.WriteSettingsEntry "Enabled", "False", , Name
modScripting.DestroyObjs Module
Command.Respond Name & " has been disabled."
Command.Respond StringFormat("Script ""{0}"" has been disabled.", Name)
For i = 1 To DynamicMenus.Count
Set mnu = DynamicMenus(i)
If (StrComp(mnu.Name, Chr$(0) & Name & Chr$(0) & "ENABLE|DISABLE", vbTextCompare) = 0) Then
@@ -182,22 +183,23 @@ Public Sub OnEnable(Command As clsCommandObj)
Dim mnu As clsMenuObj

If modScripting.GetScriptSystemDisabled() Then
Command.Respond "Error: Scripts are globally disabled via the override."
Command.Respond "Error: Scripts are globally disabled."
Exit Sub
End If

If (Command.IsValid) Then
Set Module = modScripting.GetModuleByName(Command.Argument("Script"))
Name = Command.Argument("Script")
Set Module = modScripting.GetModuleByName(Name, True)
If (Module Is Nothing) Then
Command.Respond "Error: Could not find specified script."
Command.Respond StringFormat("Error: Could not find the script ""{0}"".", Name)
Else
Name = modScripting.GetScriptName(Module.Name)
If (StrComp(SharedScriptSupport.GetSettingsEntry("Enabled", Name), "True", vbTextCompare) = 0) Then
Command.Respond Name & " is already enabled."
If (modScripting.IsScriptEnabled(Name) = True) Then
Command.Respond StringFormat("Error: Script ""{0}"" is already enabled.", Name)
Else
SharedScriptSupport.WriteSettingsEntry "Enabled", "True", , Name
Command.Respond StringFormat("Script ""{0}"" has been enabled.", Name)
modScripting.InitScript Module
Command.Respond Name & " has been enabled."
For i = 1 To DynamicMenus.Count
Set mnu = DynamicMenus(i)
If (StrComp(mnu.Name, Chr$(0) & Name & Chr$(0) & "ENABLE|DISABLE", vbTextCompare) = 0) Then

0 comments on commit 2f9732d

Please sign in to comment.
You can’t perform that action at this time.