Here is what i tried..
obj/HUD/HP
text = "<font bgcolor=#FF0033><font color=#698B69>[src.hp]</font>"
screen_loc="2,1"
Text Test.dm:219:error:src.hp:undefined var
Text Test.dm:219:error::expected a constant expression
ID:170296
Feb 17 2005, 6:17 pm
|
|
I've been experimenting with text mode lately to see what can be done with it as some of you may know and now I'm stuck again. How would you show variables on a hud in text mode?
Here is what i tried.. obj/HUD/HP Text Test.dm:219:error:src.hp:undefined var Text Test.dm:219:error::expected a constant expression |
Feb 17 2005, 6:23 pm
|
|
You can only set variables to... er, variables at run-time.
|
In response to YMIHere
|
|
<_< Heh, bl33p, just bored, hehe. G'night, sleepy time for me.
- Super Squirrel ---------------------------------------------- Ask what one cannot eat apple pie, yet not the pastry is undone to you. |
In response to YMIHere
|
|
YMIHere wrote:
You can only set variables to... er, variables at run-time. How would i accomplish this? ~>Jiskuha |
In response to Jiskuha
|
|
I notice you're using hp so I'm going to take a page from Lummox's book and use a universal TakeDamage() proc that can update the hud too. First we'll need the hud object, and a reference to it from the mob.
obj/HUD/hp_thing The next thing we have to do is create the HUD object for a mob when it logs in. mob Now we've got it all setup to use. I'm going to use it in the TakeDamage() proc, so instead of subtracting from a mob's hp variable directly, you should use it. mob |
In response to YMIHere
|
|
Okay ive done all of that however nothing is displayed on 1,1 of the client's screen..
~>Jiskuha |
In response to Jiskuha
|
|
Whoops! I forgot to add it to the screen. Just add it in Login() right after you create it and it should work fine. =)
|
In response to YMIHere
|
|
All i get on the screen is the letter H..
~>Jiskuha |
In response to Jiskuha
|
|
That's the default value of the object's text variable (the first letter of it's name). If you want to change that, change the object's text variable after you create it (in mob/Login()), or you can just wait until you're attacked. =P Keep in mind, multiple letters in the text variable will be scrolled through.
|
In response to YMIHere
|
|
Heres what i put in mob/login()
mob Did i do something wrong that it wont change the h to a number? ~>Jiskuha |
In response to Jiskuha
|
|
Yeah, I should have specified. You're creating a HUD object and adding it to the screen, then you're creating a new HUD object to be reference by the player's hpHUD variable. That variable has to reference the object that's in the player's screen, so you create hpHUD, then add hpHUD to the screen.
hpHUD=new() Now you can play with the object that is in the player's screen through that variable. =) |
In response to YMIHere
|
|
It works,Thanks a lot mate! Also since its in text mode and its more than one number/letter it cycles through all of the numbers so it will display 1 then 0 then 0 again and repeat. Is there anyway to get it to display the full 100?
~>Jiskuha |
In response to Jiskuha
|
|
You'd have to use separate object in different locations. You might want to think about just displaying the percentage of hit points if the players' hp is going to go really high.
|
In response to YMIHere
|
|
YMIHere wrote:
You'd have to use separate object in different locations. Well how could i split up the 100 and put it in different locations. This sounds a little complicated.. ~>Jiskuha |
In response to Jiskuha
|
|
[Snippet Removed, Way too buggy!]
~>Jiskuha |
In response to Jiskuha
|
|
Hmmm, remember how you did G-text?
:) Use that text seperating proc, and make it like adding a name, except change the loc and not the pixel x/y. |
In response to Hell Ramen
|
|
DeathAwaitsU has been helping me and here is what i have achieved so far..
mob/var/hp = 50 However the 2 spaces where the 4 and the 0 should be it is a blank. Any help? ~>Jiskuha |
In response to Jiskuha
|
|
Yeah um my mistake, it should be:
mob/var/hp = 50 |
In response to DeathAwaitsU
|
|
Eh.. I have one last problem. If i only have 1 digit remaining the part that would hold the second digit is gone and shows a clear space through the hud. How can i fix this? I Tried using length.
Snippet: for(var/obj/HUDTOP/HP7/O in client.screen) Compile Error: hud.dm:181:length :warning: statement has no effect ~>Jiskuha |
In response to Jiskuha
|
|
length() just returns a num.
|