Word/Name Highlighting triggers

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Word/Name Highlighting triggers

Post by Vadi »

Whenever it find a name, it calls this function:
Code: [show] | [select all] lua
function hl.highlightEnemy( who )
	if hl.paused then return end

	local c = 1;
	local k = 1;
	while k > 0 do
		if c > 3 then break; end;
		k = string.find( line, who, k )
		if k == nil then return; end
		local nC = "";
		nC = string.match( line, ".",k+string.len(who) )
		if nC == "." or nC == "," or nC == ";" or nC == ":" or nC == " " then
			k = selectString(who, c)
			if k > -1 then
				c = c + 1;
				setFgColor(255,150,150);
				if hl.raid then setBgColor(90,0,0) end
				resetFormat();
			else return 	end
		end
		k = k + string.len(who);
	end
end
line is a special variable containing the whole current line in plain text being processed, selectString selects text in buffer and returns -1 if there is no more to select, setFgColor sets the color, resetFormat resets coloring.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Word/Name Highlighting triggers

Post by Rakon »

Heiko wrote:
Rakon wrote:That does nothing to answer any of my questions whatsoever.

I know that you , AND vadi both have packages with an enemy highlighter functionality. However, your script package appears to have the same issue I'm having in instance two. It highlights the word/enemy regardless of respecting a word boundary.
Rakon, do you honestly believe that I'll bother to answer any further questions of yours in the future if you behave like this? It's more than obvious that you've never ever tried out the package, let alone bothered to look into the script to find out how things are done yourself.
Heiko,

I asked a question in great detail about certain nuances of Mudlet. I gave examples, posted code, asked 'smart' questions, and even gave screen shots. I was redirected to a DEMO script with no explanation to any of my questions.

Do you think I'll ask any more questions, or assist others after getting responses like that??

THAT is extremely frustrating. I agree with tsuujin (and thank YOU for the code and well written post explaining), if you redirect to another script without answering the questions at hand, could you at least explain the script?? It's great if people want to use the pre-made packages, but for those of us trying to write our own code for Mudlet, UNDERSTANDING how/why Mudlet does something, is better than handing off code.

I've figured out enough through my own trial and error now to have MY enemy highlighter working the way I want, with all the provisions of my first post met except instance 1. I've come to accept that this is either a limitation, or bug in Mudlet (or my function) that does NOT highlight the word at the end of a line.

I honestly, don't know how I could've phrased my first post better in order to get a well thought out, proper response of an explanation for Mudlets behavior in the given situation. I am trying to be a useful contributor so that in case I DID run across a bug,it could be fixed.

In the future, I'll just ask if anyone has a script to do what I need instead.

User avatar
Alexander Divine
Posts: 65
Joined: Mon Dec 21, 2009 7:01 pm

Re: Word/Name Highlighting triggers

Post by Alexander Divine »

Well, I don't know if that's the best way to go about it, either. I would simply state that rather than wanting to look at a script, one learns better from building code onesself, step-by-step, and would much prefer to figure out how to implement a solution at each step.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Word/Name Highlighting triggers

Post by Vadi »

If you're talking about my highligher, then it's a feature not a bug that the last word on the line isn't highlighted. I forget the reason now though.

Post Reply