Difference between revisions of "Enemy Highlighter"

From Mudlet
Jump to navigation Jump to search
(Updated link)
 
(27 intermediate revisions by one other user not shown)
Line 1: Line 1:
==Package Info==
+
=Package Info=
 
By: [[User:Phoenix| ThePhoenix]]<br>
 
By: [[User:Phoenix| ThePhoenix]]<br>
  
Line 6: Line 6:
 
Size: 4kb
 
Size: 4kb
  
Website: http://dl.dropbox.com/u/22569276/EnemyHighlighter.zip
+
Website: [http://dl.dropbox.com/u/22569276/EnemyHighlighter.zip Download it here]
 +
::[http://groups.google.com/group/phoenixcodes Feel free to join my group, where I send out notifications of updates and bug fixes!]
  
Version: 2.0 (faster and better)
+
Version: 2.7
  
 
Contents: EnemyHighlighter.xml
 
Contents: EnemyHighlighter.xml
  
Summary/Description: This system has one alias, which will allow you to colour the enemies for any Achaean organisation. Simply use 'enhi <enemy checking command>' to check them. For example, to highlight the enemies of your city, you would do 'enhi city enemies'.  
+
Summary/Description: This package is an extremely quick enemy-highlighter. It is precise, only ever highlighting the full name, and highlighting all of the full name on that line. Using obscene amounts of names on a line, you can introduce ''minor'' lag... Obscene being something such as doing 'city enemies' in '''Mhaldor''' (2000 enemies to highlight, anyone?). However, even so, it is fast to do them. Check out the [[Enemy_Highlighter#Benchmarks|benchmarks]] at the bottom. This package uses substring triggers for fastest results.
 +
<br><br>
 +
Feedback is desired. If you have any questions, send me an [[Special:EmailUser/Phoenix|email]].
  
The code is fully commented, allowing you to easily make enemies for different orgs show up different colours. Pretty much the only place you'd need to edit in the code would be between lines 5 and 9 in EnemyList trigger, adding orgs or changing the default easily, based on the templates.
+
Major thanks to [[User:Keneanung|Keneanung]] for the help with string.find and selectSection in the colorAll trigger. MAJOR thanks.
 
 
This highlighter now uses substring triggers instead of regex triggers, and the colorAll has been modified to be precise and fast. No more highlighting the wrong person! On my computer, 814 different enemies in one line get highlighted in 0.35 seconds. Doubling up, so it's highlighting 1628 words (two of each name on the line), took it 0.6 seconds.
 
Feedback is desired. If you have any questions, send me an [[Special:EmailUser/Phoenix|email]].
 
  
 
Related Packages: None.
 
Related Packages: None.
Line 24: Line 24:
 
* [[RiftTracker| Rift Tracker 2.1]]
 
* [[RiftTracker| Rift Tracker 2.1]]
  
==API==
+
=API=
===Aliases===
+
==Aliases==
  
;enhi <command>
+
===enhi===
 +
'''Syntax: enhi <command>'''
 
:This is currently the only alias in the system. It's a very simply alias - simply use 'enhi' before the normal command, to highlight them. After '''enhi''' you use the normal Achaean syntax for checking the enemies. For instance:<br>
 
:This is currently the only alias in the system. It's a very simply alias - simply use 'enhi' before the normal command, to highlight them. After '''enhi''' you use the normal Achaean syntax for checking the enemies. For instance:<br>
 
'''enhi city enemies''' - this would highlight city enemies.<br>
 
'''enhi city enemies''' - this would highlight city enemies.<br>
 
'''enhi clan example enemies''' - this would highlight all the enemies of that clan.
 
'''enhi clan example enemies''' - this would highlight all the enemies of that clan.
 +
----
 +
==Functions==
  
===Functions===
+
===colorAll()===
 +
''colorAll(word[, fg[, bg[, italic[, underline[, bold[, noCase]]]]]])''
  
'''colorAll()'''
+
This function will color all of 'word' in the line. It will not find it inside another word, only highlighting full words. All arguments aside from ''word'' are optional<br>
colorAll(word, fg, bg, italic, underline, bold, noCase)
 
 
 
This function will color all of 'word' in the line. It will not find it inside another word, only highlighting full words.<br>
 
 
;Parameters:
 
;Parameters:
 
*fg, bg
 
*fg, bg
Line 55: Line 56:
 
--They will be made italic, and the case will not matter.
 
--They will be made italic, and the case will not matter.
 
</lua>
 
</lua>
 +
----
 +
 +
===isEnemy()===
 +
''isEnemy(person[, place[, orAll]])''
 +
<br><br>
 +
This function will check to see if 'person' is an enemy to 'place', or if 'person' is a known enemy period. This function is made to be extremely quick.<br>
 +
:Parameters:
 +
*person
 +
:String value. This is the name of the person to check.
 +
*place
 +
:string value. This is an optional argument for place to check. If this place does not exist, it will default to 'false'.
 +
*orAll
 +
:Boolean value. If 'place' does not exist, will check everywhere if this is true.
 +
;Example
 +
<lua>
 +
isEnemy("Rakon","the City of Hashan", true)
 +
-- In this example, if "Rakon" is an enemy of "the City of Hashan", it will return true.
 +
-- If we do not know the enemies of his place, it will check -all- places.
 +
</lua>
 +
----
  
==Changing Enemy Colors==
+
=Changing Enemy Colors=
  
==Benchmarks==
+
=Benchmarks=
These benchmarks are done while running this highlighter in conjunction [http://svo.vadisystems.com svo]. In other words... alone, it'd probably be faster still.<br><br>
+
These benchmarks are done while running this highlighter in conjunction [https://github.com/svof/svof svo]. In other words... alone, it'd probably be faster still.<br><br>
814 enemies to search for, 1628 enemies on the line, 814 enemies (two highlights per name) - 0.6 seconds<br>  
+
;highlighter
814 enemies to search for, 106 words on the line, 53 enemies, 2 highlights per eneemy (106 highlights)- 0.008 seconds<br>
+
----
 +
0 enemies to search for, 814 words on the line, 0 highlights - 0.032 seconds to parse the line.<br>
 +
814 enemies to search for, 814 words on the line, 814 unique highlights - 0.352 seconds to parse the line.
 +
----
 +
814 enemies to search for, 1628 enemies on the line, 814 enemies (Doubled the names up, so it did two highlights per name) - 0.6 seconds<br>  
 +
814 enemies to search for, 106 words on the line, 53 enemies, each name twice per line - (106 total highlights)- 0.008 seconds<br>
 
814 enemies to search for, 5000 words on the line, 20 enemies on the line - 0.1 second<br>
 
814 enemies to search for, 5000 words on the line, 20 enemies on the line - 0.1 second<br>
814 enemies to search for, 5000 words on the line, 1 enemies name, - 0.010 seconds
+
814 enemies to search for, 5000 words on the line, 1 enemies name, - 0.010 seconds<br>
+
814 enemies to search for, 84 words on the line, 1 enemies name, - 0.003 seconds.
 +
;isEnemy
 +
10,000 iterations of isEnemy takes 0.01 seconds.
 +
 
 +
=Bugs=
 +
Ok. There are a few. Lets note them here. Feature requests too, why not.
 +
 
 +
;Submitter: [[User:Phoenix|ThePhoenix]]<br>
 +
;Bug/Feature: Checking multiple lists only formats the last list.<br>
 +
;Status: '''Fix Released 2.7'''
 +
----
 +
;Submitter: Jarrod<br>
 +
;Bug/Feature: Personal enemy lists.<br>
 +
;Status: Wishlist
 +
 
 +
=Change Log=
 +
====-v2.7-====
 +
Fixed a bug that would overwrite the colorEnemyTable, causing only lists with preset to highlight, and the last list to work with defaults.
 +
====-v2.6-====
 +
Added isEnemy, a function to check if someone is an enemy. 07.27.2011 6:50PM
 +
====-v2.5-====
 +
--Added functionality to colorAll - takes a lot more types of formatting now, as well as rgb color.
 +
--Updated enemy triggers and tables and such to match the updates.
 +
====-v2.3-====
 +
--Added enhi alias, so that it doesn't re-highlight any time you check city enemies.<br>
 +
--Added a stopwatch trigger set, to take benchmarks of 'city enemies' and such.
 +
====-v2.1-====
 +
--Minor bug in deletion of triggers, now fixed.<br>
 +
====-v2.0-====
 +
--Got rid of the highlight bug, and switched back to substrings. colorAll is now a -lot- better.<br>
 +
--Speed improvements are amazing in this release.
 +
--Thanks to [[User:Keneanung|Keneanung]] for the help with making colorAll work better and faster.
 +
====-v1.0-====
 +
--First 'final' release, all bugs are out of the system, except for a single highlight bug...<br>
 +
--Turned off the no-case pattern for enemy names, sped it up considerably.
 +
====-v0.7-====
 +
--Switched to regex trigger, allows me to specify only coloring on a word.<br>
 +
--Fixed triggers deleting themselves, they weren't always.
 +
====-v0.6-====
 +
--Bit of debugging, made triggers delete themselves before creating new.<br>
 +
--Added colorization for multiple people on a line, major issues with coloring within words
 +
====-v0.5-====
 +
--Initial script, only highglights first instance of name. City must be changed to match in trigger. Single filter trigger makes it run.<br>
 +
--Improvement from using colourizer triggers made manually.
 
[[Category:Mudlet Package Listing]]
 
[[Category:Mudlet Package Listing]]

Latest revision as of 07:00, 18 February 2017

Package Info

By: ThePhoenix

For(MUD): Achaea

Size: 4kb

Website: Download it here

Feel free to join my group, where I send out notifications of updates and bug fixes!

Version: 2.7

Contents: EnemyHighlighter.xml

Summary/Description: This package is an extremely quick enemy-highlighter. It is precise, only ever highlighting the full name, and highlighting all of the full name on that line. Using obscene amounts of names on a line, you can introduce minor lag... Obscene being something such as doing 'city enemies' in Mhaldor (2000 enemies to highlight, anyone?). However, even so, it is fast to do them. Check out the benchmarks at the bottom. This package uses substring triggers for fastest results.

Feedback is desired. If you have any questions, send me an email.

Major thanks to Keneanung for the help with string.find and selectSection in the colorAll trigger. MAJOR thanks.

Related Packages: None.

Other Packages made by this Package Author:

API

Aliases

enhi

Syntax: enhi <command>

This is currently the only alias in the system. It's a very simply alias - simply use 'enhi' before the normal command, to highlight them. After enhi you use the normal Achaean syntax for checking the enemies. For instance:

enhi city enemies - this would highlight city enemies.
enhi clan example enemies - this would highlight all the enemies of that clan.


Functions

colorAll()

colorAll(word[, fg[, bg[, italic[, underline[, bold[, noCase]]]]]])

This function will color all of 'word' in the line. It will not find it inside another word, only highlighting full words. All arguments aside from word are optional

Parameters
  • fg, bg
These arguments take either a color name from showColors(), or r,g,b format (in string).
  • italic
Boolean value. If it is true, the word will be made italic.
  • underline
Boolean value. If it is true, the word will be underlined.
  • bold
Boolean value. If it is true, the word will be made bold.
  • noCase
Boolean value. If it is true, all of <word> will be matched on the line, regardless of case.
Example

<lua> colorAll(word,"blue","134,234,12", true, false, false, true) --In this example, all of 'word' will be colored blue on a yellowy-greenish background. --They will be made italic, and the case will not matter. </lua>


isEnemy()

isEnemy(person[, place[, orAll]])

This function will check to see if 'person' is an enemy to 'place', or if 'person' is a known enemy period. This function is made to be extremely quick.

Parameters:
  • person
String value. This is the name of the person to check.
  • place
string value. This is an optional argument for place to check. If this place does not exist, it will default to 'false'.
  • orAll
Boolean value. If 'place' does not exist, will check everywhere if this is true.
Example

<lua> isEnemy("Rakon","the City of Hashan", true) -- In this example, if "Rakon" is an enemy of "the City of Hashan", it will return true. -- If we do not know the enemies of his place, it will check -all- places. </lua>


Changing Enemy Colors

Benchmarks

These benchmarks are done while running this highlighter in conjunction svo. In other words... alone, it'd probably be faster still.

highlighter

0 enemies to search for, 814 words on the line, 0 highlights - 0.032 seconds to parse the line.
814 enemies to search for, 814 words on the line, 814 unique highlights - 0.352 seconds to parse the line.


814 enemies to search for, 1628 enemies on the line, 814 enemies (Doubled the names up, so it did two highlights per name) - 0.6 seconds
814 enemies to search for, 106 words on the line, 53 enemies, each name twice per line - (106 total highlights)- 0.008 seconds
814 enemies to search for, 5000 words on the line, 20 enemies on the line - 0.1 second
814 enemies to search for, 5000 words on the line, 1 enemies name, - 0.010 seconds
814 enemies to search for, 84 words on the line, 1 enemies name, - 0.003 seconds.

isEnemy

10,000 iterations of isEnemy takes 0.01 seconds.

Bugs

Ok. There are a few. Lets note them here. Feature requests too, why not.

Submitter
ThePhoenix
Bug/Feature
Checking multiple lists only formats the last list.
Status
Fix Released 2.7

Submitter
Jarrod
Bug/Feature
Personal enemy lists.
Status
Wishlist

Change Log

-v2.7-

Fixed a bug that would overwrite the colorEnemyTable, causing only lists with preset to highlight, and the last list to work with defaults.

-v2.6-

Added isEnemy, a function to check if someone is an enemy. 07.27.2011 6:50PM

-v2.5-

--Added functionality to colorAll - takes a lot more types of formatting now, as well as rgb color. --Updated enemy triggers and tables and such to match the updates.

-v2.3-

--Added enhi alias, so that it doesn't re-highlight any time you check city enemies.
--Added a stopwatch trigger set, to take benchmarks of 'city enemies' and such.

-v2.1-

--Minor bug in deletion of triggers, now fixed.

-v2.0-

--Got rid of the highlight bug, and switched back to substrings. colorAll is now a -lot- better.
--Speed improvements are amazing in this release. --Thanks to Keneanung for the help with making colorAll work better and faster.

-v1.0-

--First 'final' release, all bugs are out of the system, except for a single highlight bug...
--Turned off the no-case pattern for enemy names, sped it up considerably.

-v0.7-

--Switched to regex trigger, allows me to specify only coloring on a word.
--Fixed triggers deleting themselves, they weren't always.

-v0.6-

--Bit of debugging, made triggers delete themselves before creating new.
--Added colorization for multiple people on a line, major issues with coloring within words

-v0.5-

--Initial script, only highglights first instance of name. City must be changed to match in trigger. Single filter trigger makes it run.
--Improvement from using colourizer triggers made manually.