I have a draw text command that goes like this:
draw_text(x+515,y+55,player_gun.magazine/player_base.ammo)
In my HUD object, it displays fine, but I can't figure out how to get it to actually display the two variables in the string the way I want. I want them to display like this:
50/100
but I get this:
0.50
basically, I want to negate the division and just display a slash between the two values. How would I do this?
Wouldn't the / need to be in quotation marks so it knows to print it as text and not part of an equation?
that's what I thought, and I tried that.
___________________________________________
FATAL ERROR in
action number 12
of Draw Event
for object HUD_parent:
COMPILATION ERROR in code action
Error in code at line 4:
draw_text(x+515,y+55,player_gun.magazine"/"player_base.ammo)
^
at position 43: Symbol , or ) expected.
Hmm, see, I'm not too great with GML, so I'm just guessing lol.
How about...
draw_text(x+515,y+55,(player_gun.magazine+"/"+player_base.ammo))
Again, just guessing lol, not sure how to do this.
If + doesn't work try .
draw_text(x+515,y+55,player_gun.magazine+"/"+player_base.ammo)
draw_text(x+515,y+55,player_gun.magazine."/".player_base.ammo)
One of those I'd imagine.
tried all of these (and more) and still nothing, so I got fed up with it and rewrote the code and changed it to display the two numbers as a fraction like this:
50
100
and I actually like it better this way so consider this solved :thumb:
I know you found another solution, but just fyi you can solve the problem by getting the string representation of the numbers and use standard string concatenation:
draw_text(x + 515, y + 55, player_gun.magazine.to_s + "/" + player_base.ammo.to_s)
*hugs*