Closed jpcsupplies closed 8 years ago
Not enough )'s
:laughing:
Okay, I'll look at it tonight.
I think you need to establish a good pattern on how you expect the users to type stuff in first. What you have is very mixed up in terms of words and values.
/set
"item name" (to set the on hand stock of an item) /set blacklist "item name" (to toggle blacklist on or off (depending on current state)) /set buy "item name" /set sell "item name"
I expected /set <keyword> <itemname> <value1> <value2>
But the first command doesn't conform with the rest, and thus makes it harder to put into one RegEx.
the patterns to check for are: Setting on hand: /set 100 "item name" (if {1} is number)
Toggling blacklist on or off: /set blacklist "item name" (if {1} is a string)
Setting the buy or sell price (or any other option we want really) /set buy|sell "itemname" 100 (if {1} is a string (= buy|sell) and {3} is a number)
Really it only needs the first two tests, and make the 3rd parameter optional - we can work out what is going on by checking the {1}
Throws exception trying to use any set commands looks like i broke the regex for it.. https://github.com/jpcsupplies/Economy_mod/commit/563c804e0d19366ddc40cea5041ac3a77f63d174
You able to do some regex magic? see error below; looks like i am missing an ")" somewhere.
2015-11-19 09:28:16:503 - Economy Client Log Started 2015-11-19 09:28:16:503 - Economy Client Version 20151116 2015-11-19 09:28:16:994 - HandleMessage 2015-11-19 09:28:17:686 - HandleMessage 2015-11-19 09:28:17:697 - Received - MessageConnectionResponse 2015-11-19 09:28:21:310 Error - System.ArgumentException: parsing "(?/set)\s+(?:(?[+-]?((\d+(.\d)?)|(.\d+)))|(?buy))\s+(?:(?:"(?- [^"]|(?
sell))\s+(?:(?:"(?- [^"]|.
?)")|(?blacklist))\s+(?:(?:"(?- [^"]|.?)")|(?
- .
(?=\s+\d+\b))|(?- .$))(?:\s+(?
[+-]?((\d+(.\d )?)|(.\d+)))(?:\s+(?:(?:"(?[^"]|.?)")|(?[^\s] )))?)?" - Not enough )'s.
at System.Text.RegularExpressions.RegexParser.ScanRegex()
at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
at System.Text.RegularExpressions.Regex.Match(String input, String pattern, RegexOptions options, TimeSpan matchTimeout)
at Economy.scripts.EconomyScript.ProcessMessage(String messageText)
at Economy.scripts.EconomyScript.GotMessage(String messageText, Boolean& sendToOthers)
2015-11-19 09:28:30:306 - BuildComponentLists
2015-11-19 09:28:30:321 - HandleMessage
2015-11-19 09:28:30:352 - HandleMessage
2015-11-19 09:28:30:362 - Received - MessageClientTextMessage
2015-11-19 09:28:45:669 Error - System.ArgumentException: parsing "(?/set)\s+(?:(?[+-]?((\d+(.\d)?)|(.\d+)))|(?buy))\s+(?:(?:"(?- [^"]|(?
sell))\s+(?:(?:"(?- [^"]|.
?)")|(?blacklist))\s+(?:(?:"(?- [^"]|.?)")|(?
- .
(?=\s+\d+\b))|(?- .$))(?:\s+(?
[+-]?((\d+(.\d )?)|(.\d+)))(?:\s+(?:(?:"(?[^"]|.?)")|(?[^\s] )))?)?" - Not enough )'s.
at System.Text.RegularExpressions.RegexParser.ScanRegex()
at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
at System.Text.RegularExpressions.Regex.Match(String input, String pattern, RegexOptions options, TimeSpan matchTimeout)
at Economy.scripts.EconomyScript.ProcessMessage(String messageText)
at Economy.scripts.EconomyScript.GotMessage(String messageText, Boolean& sendToOthers)
2015-11-19 09:28:53:642 - Closed