sending text to miniconsole with a specific colour

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

sending text to miniconsole with a specific colour

Post by Caled »

Code: Select all

function csecho(col, mess)
	setFgColor(255,0,0)
	echoUserWindow("roomwin", "\n")
	echoUserWindow("roomwin", mess)
end
setFgColor() applies to a selection, such as selectString, which is then passed to the console with appendBuffer() or similar.

Obviously, it does not work in the above function, because I have no text selected. I'm using that function to print useful messages of my own compilation, to the console, so there is nothing to actually select.

How can I change the colour of what I am printing in my miniconsole with echoUserWindow()?

Thylacine
Posts: 28
Joined: Sun May 10, 2009 5:04 am

Re: sending text to miniconsole with a specific colour

Post by Thylacine »

Caled, I can't remember if I mentioned this in IRC...

setTextFormat has been re-enabled in the latest source release, although the 'red' component of the foreground colour is broken, here's a template (bg/fg is background/foreground, r/g/b are just colours):
setTextFormat(window, bg_r, bg_g, bg_b, fg_r, fg_b, fg_g, bold, italics, underline)

Where the last three can be 0 or 1. The other problem with setTextFormat is that it needs to be called before writing any text, else all the old crap remains the same colour. I don't think that'll be a problem for you, though.

I've been trying to use moveCursor and moveCursorEnd. along with selectCurrentLine or selectString(line,1) to change existing text. But for whatever reason the move commands wont let the cursor leave the main window. Even if I use moveCursor("notes", 1, 1), deleteLine() will just operate on the first line in the main window...

So yeah, I'm not sure how sorry :(

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: sending text to miniconsole with a specific colour

Post by Heiko »

deleteLine(), selection etc. operate on the line of the user cursor. Are you sure moveCursor( windowName, y, x ) is broken?
I'll have a look.

Thylacine
Posts: 28
Joined: Sun May 10, 2009 5:04 am

Re: sending text to miniconsole with a specific colour

Post by Thylacine »

Well the new functions have been working great on miniconsoles and whatnot, but for whatever reason I cannot get them to work on labels...

Not sure if this is just an implication thing or not, but none of the functions bar "setBackgroundColor" seem to work on labels anymore. At the moment, my label's foreground is this horrible grey colour which is impossible to read unless you're 12mm away from the screen.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: sending text to miniconsole with a specific colour

Post by Heiko »

They don't work for labels. For labels you can use html for text formating. Just a short note on the background problems as I don't have time: There is an option to fill the background. The degree of transparency is also what you need to look out for. The font, f. size, color etc. must be set via HTML. The background color should work. Check the debug console. There might be some Lua function that dosesnt work correctly after the recent updates. I haven't run any tests yet.

Post Reply