Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Is this correct? syntax error

Untra

Sponsor

I'm trying to edit my equipment menu so that when it shows the @new_atk, @new_pdef etc. It changes the font color depending on if the change is negative or positive.
Code:
    if @new_atk != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 160, 40, 32, "->", 1)
      self.contents.font.color = actor.atk > @new_atk ? (127, 0, 0, 255)
      actor.atk < @new_atk ? (0, 0, 127, 255) : (255, 255, 255, 255)
      self.contents.draw_text(200, 160, 36, 32, @new_atk.to_s, 2)

This gives me a syntax error and I'm not sure as to why it does that. Its probably very obvious, and I'm an idiot. The main edit to the original is the 4th and 5th lines shown. Help?

Edit: I'm editing the window_EquipLeft here.
 
1st- The (127, 0, 0, 255) wont do anything by their own, it should be Color.new(127, 0, 0, 255)
2nd- You missed a ":" in the 4th line in the end.
Fixed code:
Code:
if @new_atk != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 160, 40, 32, "->", 1)
      self.contents.font.color = actor.atk > @new_atk ? Color.new(127, 0, 0, 255) :
      actor.atk < @new_atk ? Color.new(0, 0, 127, 255) : Color.new(255, 255, 255, 255)
      self.contents.draw_text(200, 160, 36, 32, @new_atk.to_s, 2)

Later
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top