ID:174026
 
Anyone know of a pretty good and easy to use text on screen demo? I'm trying to make the player's health on their screen. I thought Raekwon had one, I'm looking for it now. Thanks!

[edit]
I found Raekwons demo, but it seems a bit hard to use. How could I get rid of the background stuff, and make the text constantly be there?
Airjoe wrote:
Anyone know of a pretty good and easy to use text on screen demo? I'm trying to make the player's health on their screen. I thought Raekwon had one, I'm looking for it now. Thanks!

You can use DmiFonts for that. This will work best with a non-antialiased font.

The following example creates a meter of an arbitrary color, aligned to the right and bottom.
var/dmifont/ComicSansMSBold10pt/statfont = new

obj/meter
var/mob/M
var/client/client
var/varname
var/maxname
var/RGB

New(client/C, Y, varname, maxname, r, g, b)
if(C)
client = C
M = C.mob
if(!(varname in M.vars)) del(src)
if(!(maxname in M.vars)) del(src)
src.varname = varname
src.maxname = maxname
screen_loc = "EAST,SOUTH[Y?"+[Y]":""]"
C.screen += src
RGB = rgb(r, g, b)
Update()

proc/Update()
if(!M || M.client != client) del(src)
var/v = M.vars[varname]
var/mx = M.vars[maxname]
var/txt = "[v]/[mx]"
var/w = statfont.RoundUp32(statfont.GetWidth(txt))
var/iconset/s = statfont.DrawText(txt, w - 3, 29 - statfont.height,\
width = w, flags = DF_JUSTIFY_RIGHT,\
icons_y = 1)
// make a border around the numbers
s.Dilate()
s.Invert()
S.Transparent(255)
// draw new numbers over it
statfont.DrawText(txt, w - 3, 29 - statfont.height,\
width = w, flags = DF_JUSTIFY_RIGHT,\
drawover = s)
// add color
s.Blend(RGB, ICON_MULTIPLY)
// set icons
overlays.Cut()
icon = s.GetIcon(s.w - 1, 0) // use the rightmost icon
if(s.w > 1)
var/obj/O = new
O.layer = layer
for(var/obj/i = s.w - 2, i >= 0, --i)
O.pixel_x -= 32
O.icon = s.GetIcon(i, 0)
overlays += O
del(O)

mob
var/HP, maxHP = 10
var/MP, maxMP = 10
var/tmp/obj/meter/healthmeter // the /tmp is important!

New()
HP = maxHP
MP = maxMP

Login()
..()
healthmeter = new(client, 0, "HP", "maxHP", 0, 255, 0)
magicmeter = new(client, 1, "MP", "maxMP", 192, 0, 255)

Lummox JR
It's not technically Raekwon's. That demo of "his" uses my old map-text code. I made the mistake of letting him see it once when I was trying to teach him how to make a menu for his Dragon Warrior game, and he made the demo out of my code without giving me credit. (At least I didn't notice any credit last time I saw "his" demo.)
In response to Loduwijk
Loduwijk wrote:
It's not technically Raekwon's. That demo of "his" uses my old map-text code. I made the mistake of letting him see it once when I was trying to teach him how to make a menu for his Dragon Warrior game, and he made the demo out of my code without giving me credit. (At least I didn't notice any credit last time I saw "his" demo.)

Oh yeah, that's right. Suuree. >_<


RaeKwon
Try this http://developer.byond.com/hub/DarkEmrald/texting if you cant figure out how to use varibales such as health to display on screen. Juss say and ill edit the demo a little more to show how its done.
In response to Dark Emrald
You do know you just responded to a post that's over 3 years old, right?
In response to Airjoe
O.o XD now thats hilarious next time ill look at the date >> than respond.
In response to Lummox JR
I had a question about the following function.

//proc/DrawText(text, x, y, width=-1, flags=0, firstline=0, maxlines=-1, icons_x=0, icons_y=0, iconset/drawover, list/leftover)


When I change the input for 'x', I get a lot of different results. Can someone help me understand what x does? Changing from 6 to 7 makes the text change drastically but I can't figure out why.
In response to Dark Emrald
That's because my posts are being deleted for some reason. Any ideas?
In response to Tsfreaks
Tsfreaks wrote:
I had a question about the following function.

> //proc/DrawText(text, x, y, width=-1, flags=0, firstline=0, maxlines=-1, icons_x=0, icons_y=0, iconset/drawover, list/leftover)
>

When I change the input for 'x', I get a lot of different results. Can someone help me understand what x does? Changing from 6 to 7 makes the text change drastically but I can't figure out why.

Well, my guess would be that x and y are screen_loc coordinates.
In response to DivineO'peanut
It would seem that simple but it doesn't work out so that way.

I beleive this particular x and y are the pixel offsets.

Some of the problems I'm having are as follows.

The text dissapears entirely when I go from x=24 to x=25 which I don't understand. Where does it go?

I got the QuickText to work great but that didn't meet my needs because I need this for my hud.

I know this is a little vague but someone who is familiar with the library should be able to help if they have any experience with it.

I hope so that is.
In response to Tsfreaks
Try this http://developer.byond.com/hub/DarkEmrald/texting I added a hud demonstration.

- Dark Emrald
In response to Dark Emrald
You really should include the icons so it compiles.
In response to Xx Dark Wizard xX
O.o Ok for some reason it didnt add the main player icon, but anywho it should be there now.
In response to Dark Emrald
Dark Emrald wrote:
Try this http://developer.byond.com/hub/DarkEmrald/texting I added a hud demonstration.

- Dark Emrald


That's a pretty cool demo. Very nice. I'll take a closer look at your meter implementation to see if something similiar would work for what I'm trying to do. I have several issues which are making this a challenge for me.

Scores or numbers which go into the billions.
The need for enter aligned text.
I also have a middle layer of hud transparency which has reaked havoc on the text (color) I'm trying to put above it.

It's been a long week with minimal progress so this is good for spirits. :)

Thanks,
tsfreaks
In response to Dark Emrald
Since we are on the subject of adding text into a game and using your demo, can I get the letters to be spaced less apart than just 32 pixels? I got it to go to 16 pixels between each letter, but I would like it to go from about 8 to 12 pixels but I don't know how. Any thoughts Dark Emrald or anyone else?
In response to Dark Emrald
This is probably the easist text to hud implementation I've used. It almost meets my needs as-is but the font size is static so it doesn't fit well with my current UI. :(

This is just one of those things that you would think is easy but it's far from.

"Hello World!"

The demo is great and I'm sure many other people will find it extremly convienient and useful.

Thanks,
tsfreaks



In response to Tsfreaks
Actually, I may try to get this to work afterall. It's just to easy to pass up. A little UI rework and I can make things fit up to the millions and maybe 10's of millions. I won't be able to get into the billions but I should be able to figure something out.

When I repost a classified ad for help on this project, I intend to show a screenshot of the entire HUD UI in its mostly finished state. If all goes well, you will see your handy work at that time.

Thanks.
In response to Tsfreaks
Np man, I will also make an text Adjuster for it as well in case people want to make their own icon text and dont know how to mod the source so they could be spaced properly.

- Dark Emrald
In response to Dark Emrald
That would be awesome...I can't get it to space exactly the way I need it, so if you'd do that, I want to be the first to know. ^_^
Page: 1 2