ID:869408
 
Keywords: buffy, map, slayer, text, the, vampire
(See the best response by Zaoshi.)
Being a novice programmer, I was trying to come up with a simple way to display a gold counter on screen. I tried to use maptext like so...
var/gold=0

obj/HUD
layer = 99
New(client/C)
screen_loc=locc
C.screen+=src

Goldcount
icon='Gold.dmi'
locc = "2,24"
maptext_width = 96
maptext_height = 128
maptext = gold

(Just a quick example)

But the compiler tells me I need a constant expression. Is there a way to have maptext output change based on a variable?

I am not sure if map text can output the variable itself like that.

I haven't explored maptext that much but it might be worth trying

maptext = "[gold]"


On another not that gold variable doesn't belong to a client so it's a global variable.

It will still display a result though.
Nope, it still gives me this...

HUD.dm:35:error: : expected a constant expression

I was hoping for some sort of variable or workaround that would allow for map text to update based on a variable.
Is that code example on line 35?

And what is locc ?
In response to A.T.H.K
Yes the line with the maptext=gold is on 35. locc(location client) are the coordinates for the image on the client. The imagine being a background for the text to appear over.
Best response
When you write maptext = gold or maptext = "[gold]" you're trying to say "maptext must always equal to gold", however DM doesn't support such feature. You'll need to change maptext value manually whenever gold changes.
In response to Zaoshi
Would something like text2number, add the amount being picked up, and using number2text work?
Not best way, but it should work.
You can keep the gold variable a number. Whenever you update your maptext, just set it to "[gold]". Then you won't have to do any text2num().
In response to Albro1
Thanks, it works perfectly now.
In response to Albro1
Albro1 wrote:
You can keep the gold variable a number. Whenever you update your maptext, just set it to "[gold]". Then you won't have to do any text2num().

Isn't that what I said :/
In response to A.T.H.K
Yes, yes it is.