some new suggestions and some bugs???

Posted by Smeagol on Sun 13 Oct 2002 03:49 AM — 7 posts, 28,092 views.

#0
First, I really want to add that mushclient is really nice on how it lets you script... I was just wondering if anybody ran into this problem... whenever i send a command in the timer like /world.DeleteVariable("test") it doesn't do it, and the only way i found around it was to send a note like delete("test") and a trigger would catch it and delete it, it seems that the text the timer sends should go through the interpretter before it gets sent into the output... i think that you should add a folder like zmud for triggers/alias/timers/variables/, and more options, like buttons, or buttons with text in them... and we should have our own status line above the command input and have a box option in preferences to have what variables/words we want in it... i also want you to know that the colourTell is very hard to use when things get really complicated and i know that this is how it is done in like java or c++, but i am wondering if there is a faster way to do it rather than world.ColourTell("black", "green", "Here,"); world.ColourTell("blue", "green,", "I"); world.ColourTell("white", "green", "am."); maybe something like world.Tell("green", %colour(black)"Here," + %colour(blue)"I" + %colour(white)"am."); You understand?? these are just suggestions but like if it makes your program slower.. don't do it...
Australia Forum Administrator #1
"Send text" in timers and triggers does not go through the command interpreter, you are right, however you can make them call a script, and in the script do:

world.deletevariable "test"

You can set the status bar (at the bottom below the command window) in a script.

You could make your own interpreter for colour codes if you wanted to with a bit of scripting (eg. ~r becomes red, that sort of thing). Perhaps in a future version that could become a built-in option.
USA #2
How would you script it in jscript so that ~r would make the next word red. I don't see any thing in your functions list that could do this... Maybe a return call could do it... Give some suggestions...
Australia Forum Administrator #3
What I meant was that you would write a routine that takes some text, looking for special characters (like ~) and does the world.colournote for you.

Something like this:

Split the text at ~ characters
Look for a letter after the ~
Do the appropriate world.colournote
Send the rest of the text in that block

USA #4
okay i actually have some code to match triggers with ~.

function misc_color(thename, theoutput, wildcardsVB) {
wildcards = VBArray(wildcardsVB).toArray();
var t_tell = world.Trim(wildcards[0]);
var t_color = t_tell.slice(0, 2);
var t_string = t_tell.slice(2);
var t_colourFore1 = world.GetVariable("colour_fore1");
var t_colourFore2 = world.GetVariable("colour_fore2");
var t_colourDisplay = world.GetVariable("colour_display");
var t_colourBack1 = world.GetVariable("colour_back1");

if(t_color == "ti") world.ColourTell(t_colourFore2, t_colourBack1, t_string);
else if(t_color == "di") world.ColourTell(t_colourDisplay, t_colourBack1, t_string);
else if(t_color == "no") world.ColourTell(t_colourFore1, t_colourBack1, t_string);
}

and my trigger is ~(\w*)

i tested it with the "Test Trigger" and it doesn't seem to work, seems like your trigger parser does work if i do something like ~tiI ~diam ~noweird it only get's like the first one ~tiI and will only display I with the desingated number. I even tried options like repeat on same line and keep evaluating but it doesn't seem to to work. and when i send it through a note/tell like world.Tell("~tiI") the trigger parser doesn't catch it which really sucks.... so it would be useless because that was the whole point...
USA #5

function z(str1, str2) {
	var t_string = str1;
	var regular = /%(d|n|r|s|t)/g;
	var t_color = new Array();
	var counter = 0;
	var t_array = new Array();

	var t_colourFore1 = world.GetVariable("colour_fore1");
	var t_colourFore2 = world.GetVariable("colour_fore2");
	var t_colourDisplay = world.GetVariable("colour_display");
	var t_colourBack1 = world.GetVariable("colour_back1");
	var t_colourReceive = world.GetVariable("colour_receive");
	var t_colourSend = world.GetVariable("colour_send");
	
	while ((t_color = regular.exec(t_string)) != null) {
		t_array[counter] = t_color.index;
		t_array[counter + 1] = t_color.lastIndex;
		t_array[counter + 2] = t_color[1];
		counter += 3;
	}
	
	if(str2 == null) zb();
	if(t_array[0] == null) world.ColourTell(t_colourFore1, t_colourBack1, str1);
	else {
		if(t_array[0] != "0") world.ColourTell(t_colourFore1, t_colourBack1, t_string.substring(0, t_array[0]));
		for(var k = 0; k <= counter; k += 3) {
			if(t_array[k + 3]) {
				if(t_array[k + 2] == "d") world.ColourTell(t_colourDisplay, t_colourBack1, t_string.substring(t_array[k + 1], t_array[k + 3]));
				else if(t_array[k + 2] == "n") world.ColourTell(t_colourFore1, t_colourBack1, t_string.substring(t_array[k + 1], t_array[k + 3]));
				else if (t_array[k + 2] == "r") world.ColourTell(t_colourReceive, t_colourBack1, t_string.substring(t_array[k + 1], t_array[k + 3]));
				else if (t_array[k + 2] == "s") world.ColourTell(t_colourSend, t_colourBack1, t_string.substring(t_array[k + 1], t_array[k + 3]));
				else if (t_array[k + 2] == "t") world.ColourTell(t_colourFore2, t_colourBack1, t_string.substring(t_array[k + 1], t_array[k + 3]));
			}
			else {
				if(t_array[k + 2] == "d") world.ColourTell(t_colourDisplay, t_colourBack1, t_string.substr(t_array[k + 1]));
				else if(t_array[k + 2] == "n") world.ColourTell(t_colourFore1, t_colourBack1, t_string.substr(t_array[k + 1]));
				else if (t_array[k + 2] == "r") world.ColourTell(t_colourReceive, t_colourBack1, t_string.substr(t_array[k + 1]));
				else if (t_array[k + 2] == "s") world.ColourTell(t_colourSend, t_colourBack1, t_string.substr(t_array[k + 1]));
				else if (t_array[k + 2] == "t") world.ColourTell(t_colourFore2, t_colourBack1, t_string.substr(t_array[k + 1]));
			}
		}
	}
	if(str2 == null) world.ColourTell(t_colourDisplay, t_colourBack1, "\n");
}


i think this solved my whole color script stuff...

Edited by Nick to add [code] to make it more readable.
Amended on Tue 22 Oct 2002 09:52 PM by Nick Gammon
Australia Forum Administrator #6

I was thinking of something along the lines of a plugin I just wrote. See Sending coloured text to the world window with ease

Once you have this function you can do things like this:

ColourNote "~R red ~G green ~B blue ~RY red-on-yellow"