|
Joined: Jan 2011
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Jan 2011
Posts: 10 |
I have an old script. http://pastebin.com/qVq97qwHBut I need it changed a bit, I had it semi working the way I wanted, but I could never get it to add anything cause this one is looking for decimals. (which the new game doesn't have) So basically, I need this script to be altered just slightly. It only needs 4 stats now; Offense Defense Spy Offense Spy Defense Stats are in this format now; 123,299,759 Instead of it looking for a decimal. (hahah regex doesn't make much sense to me, i've spent forever reading it -_- http://www.hawkee.com/phpBB2/viewtopic.php?t=9764) 123,342.123 The rest of it should be fine, unless someone wants to rewrite it. Same exact concept. Edit: I forgot, it also looks for the semi-colon to be in there, that doesn't need to included either. Stats should be entered something like this; [yadigg] offense=2,536,135 defense=1,001,544 spy offense=1,280,310 spy defense=1,200,300,439 anyway you could when it was last updated. like when it replies. sayyy.. [yadigg] offense=2,536,135 defense=1,001,544 spy offense=1,280,310 spy defense=1,200,300,439 Stats added on "date here".
Last edited by oursickstory; 04/07/12 03:31 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,358
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,358 |
Besides the differing stats I also enforced proper comma placement (or optionally no commas) in the value, and store the value with commas. The regex allows for differing -se/-ce endings for American/British spelling. alias comma {
var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
return %a
}
on *:text:!spy*:#:{
if ($1 == !spyadd) {
var %nick = $2, %stats = $3-, %i = 1
var %regex = /((?:spy )?(?:of|de)fen(?:c|s)e):?\s+(\d{1,3}(?:,\d\d\d)*(?:\s|$)|\d+)/gi
if ($regex(%stats,%regex)) && ($regml(0) == 8) {
while ($regml(%i)) {
var %stat = $replace($v1,ce,se,$chr(32),.), %value = $comma($regml($calc(%i + 1)))
writeini $scriptdirspy.ini %nick %stat %value
inc %i 2
}
writeini $scriptdirspy.ini %nick edited $date
msg $chan %nick $+ 's 3stats added to the database!
}
else {
msg $chan 4Sorry something is missing, the proper format is "!spyadd <nick> speed: $chr(35) strength: $chr(35) defense: $chr(35) dexterity: $chr(35) level: $chr(35) total: $chr(35) $+ " the order of the four stats is not important.
}
}
elseif ($1 == !spy) {
var %nick = $2
if ($ini($scriptdirspy.ini,%nick)) {
msg $chan 6 $+ %nick $+ 's stats are:
msg $chan 6Offense: $readini($scriptdirspy.ini,n,%nick,offense)
msg $chan 6Defense: $readini($scriptdirspy.ini,n,%nick,defense)
msg $chan 6Spy Offense: $readini($scriptdirspy.ini,n,%nick,spy.offense)
msg $chan 6Spy Defense: $readini($scriptdirspy.ini,n,%nick,spy.defense)
}
elseif (%nick) msg $chan 4sorry %nick is not in the database!
else msg $chan 4You need a nick for me to look up anything silly.
}
}
Last edited by Loki12583; 04/07/12 09:34 PM.
|
|
|
|
Joined: Jan 2011
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Jan 2011
Posts: 10 |
Two things, works way better then what I had, but so much more confusing....so...much..confusion ha.
The bot is replying as is. [16:06:27] IWillNotChange: !stats yadigg [16:06:28] GhostWarfare: yadigg's stats are: [16:06:28] GhostWarfare: Offense: 99, [16:06:28] GhostWarfare: Defense: 0 [16:06:28] GhostWarfare: Spy Offense: 0 [16:06:28] GhostWarfare: Spy Defense: 0
(offense is 99,759) Second, when typing !addspy offense blah blah blah can offense be capital as well? Its picky if one is off. [like Offense offense Spy Defense spy defense]
(I feel like Im missing something else, but I cant seem to think of it >.<)
Last edited by oursickstory; 04/07/12 08:13 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,358
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,358 |
Sorry, I forgot to put the case-insensitivity back in. That's done with the 'i' modifier: /regex/i. The stats were wrong because I was looking for a non-space \S instead of a space \s. I've edited my original post with these fixes.
It pretty much works the same way as the one you provided, with a slightly different regex. I'll explain the parts of it below so you can better understand what's going on.
/((?:spy )?(?:of|de)fen(?:c|s)e):?\s+(\d{1,3}(?:,\d\d\d)*(?:\s|$)|\d+)/gi
((?:spy )?(?:of|de)fen(?:c|s)e) - This part matches (all four) stats. (?:spy )? is optional, and will match the 'spy' text. (?:of|de)fen(?:c|s)e) matches the words offense/offence/defense/defence. The name of the stat is captured here, and used later when writing to the file.
:?\s+ - This matches the optional : after the stat, and the space before the value.
(\d{1,3}(?:,\d\d\d)*(?:\s|$)|\d+) - This matches properly formatted numbers with commas, or numbers with no commas. First it looks for 1 to 3 digits \d{1,3}. Next, it looks for zero or more repetitions of a comma followed by three digits ,\d\d\d. After these digits there needs to be a space or end of line \s|$. If this kind of comma number doesn't match, it tries to match a number without any commas \d+
//gi - 'g' is for global. It will apply the regex continously until it reaches the end of the line. In this way it will go over all four stats, without this, it would stop processing after the first stat is matched. 'i' is for case insensitiviy.
Last edited by Loki12583; 04/07/12 10:21 PM.
|
|
|
|
Joined: Jan 2011
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Jan 2011
Posts: 10 |
I can't thank you enough for taking time out of your day to explain it a little more for me, it means more then you think. I still have a lot to learn about, but seeing it and having it explained help so much more then trying to decode it, again, thank you so much. Means a lot more then I could begin to explain.
|
|
|
|
|