File tree Expand file tree Collapse file tree 1 file changed +29
-13
lines changed
Expand file tree Collapse file tree 1 file changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -393,19 +393,6 @@ internal bool RunCommand(string rawInput)
393393
394394 try
395395 {
396- // Allow bools to be in the form of "0" and "1"
397- if ( command . Parameters [ i ] . Type == typeof ( bool ) && int . TryParse ( parameter , out int result ) )
398- {
399- if ( result == 0 )
400- {
401- parameter = "false" ;
402- }
403- else if ( result == 1 )
404- {
405- parameter = "true" ;
406- }
407- }
408-
409396 // Try to convert the parameter input into the appropriate type
410397 parameters [ i ] = ParseParameter ( parameter , command . Parameters [ i ] . Type ) ;
411398 }
@@ -1633,7 +1620,36 @@ void logChildren(GameObject obj, int tabAmount)
16331620
16341621 private void InitBuiltInParsers ( )
16351622 {
1623+ AddParameterType ( typeof ( bool ) ,
1624+ s =>
1625+ {
1626+ // Allow bools to be in the form of "0" and "1"
1627+ if ( int . TryParse ( s , out int result ) )
1628+ {
1629+ if ( result == 0 )
1630+ {
1631+ return false ;
1632+ }
1633+ else if ( result == 1 )
1634+ {
1635+ return true ;
1636+ }
1637+ }
1638+
1639+ return Convert . ChangeType ( s , typeof ( bool ) ) ;
1640+ } ) ;
1641+
1642+ AddParameterType ( typeof ( bool ? ) ,
1643+ s =>
1644+ {
1645+ // Allow null value, representing a toggle
1646+ if ( s . ToLower ( ) == "null" || s . ToLower ( ) == "toggle" || s == "~" || s == "!" )
1647+ {
1648+ return null ;
1649+ }
16361650
1651+ return ParseParameter ( s , typeof ( bool ) ) ;
1652+ } ) ;
16371653 }
16381654
16391655 private void InitAttributeCommands ( )
You can’t perform that action at this time.
0 commit comments