Difference between revisions of "Enemy Highlighter"

From Mudlet
Jump to navigation Jump to search
Line 24: Line 24:
 
* [[RiftTracker| Rift Tracker 2.1]]
 
* [[RiftTracker| Rift Tracker 2.1]]
  
==Commands==
+
==API==
 +
===Aliases===
 +
 
 +
;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>
 +
'''enhi city enemies''' - this would highlight city enemies.<br>
 +
'''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.<br>
 +
;Parameters:
 +
*fg, bg
 +
:These arguments take either a color name from [[Manual:Lua_Functions#showColors|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>
  
 
==Changing Enemy Colors==
 
==Changing Enemy Colors==

Revision as of 19:57, 27 July 2011

Package Info

By: ThePhoenix

For(MUD): Achaea

Size: 4kb

Website: http://dl.dropbox.com/u/22569276/EnemyHighlighter.zip

Version: 2.0 (faster and better)

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'.

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.

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 email.

Related Packages: None.

Other Packages made by this Package Author:

API

Aliases

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.

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>

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.

814 enemies to search for, 1628 enemies on the line, 814 enemies (two highlights per name) - 0.6 seconds
814 enemies to search for, 106 words on the line, 53 enemies, 2 highlights per eneemy (106 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