Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 7 posts ] 
    Dr. Funk
  Tue Mar 08, 2011 11:37 pm
I AM THE RAP GAME
User avatar
Member

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?


Top Top
Profile      
 

    Jason
  Tue Mar 08, 2011 11:46 pm
User avatar
Awesome Bro

Generic Townsperson
Wouldn't the / need to be in quotation marks so it knows to print it as text and not part of an equation?

_________________
This is a block of text that can be added to posts you make. There is a 9999 character limit.


Top Top
Profile      
 

    Dr. Funk
  Tue Mar 08, 2011 11:58 pm
I AM THE RAP GAME
User avatar
Member

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.


Top Top
Profile      
 

    Jason
  Wed Mar 09, 2011 12:05 am
User avatar
Awesome Bro

Generic Townsperson
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.

_________________
This is a block of text that can be added to posts you make. There is a 9999 character limit.


Top Top
Profile      
 

    Amy
  Wed Mar 09, 2011 12:31 am
User avatar
Staff

Big Dumb Guy
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.


Top Top
Profile      
 

    Dr. Funk
  Wed Mar 09, 2011 2:21 am
I AM THE RAP GAME
User avatar
Member

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:


Top Top
Profile      
 

    Zeriab
  Sat Mar 12, 2011 9:25 am
Hugging Lion
User avatar
Sponsor

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*

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group