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.

Cannot convert fixnum into array

Okay, whenever I try to make my Battle Formulas work, I always get a Cannot convert Fixnum into Array from this line:
atk = [attacker.atk - self.pdef / 2, 0].max

THats just slightly edited from the standard one, but even with that I'm now getting an error >.<

Any Help?
 
Hm.. probably he has a problem with the formula inside the array. Try using parenthesis
Code:
atk = [(attacker.atk - self.pdef / 2), 0].max
If that doesn't work, use the formula outside of the array and save the result in a temporary variable.
Edit:
Oh and are you sure "attacker.atk" and "self.pdef" return both integers, and not an array? Probably another script you use changed this.
 
The parenthesis like that don't work Lobosque.

.max is an Array method that returns the highest integer value in the array. In the case above, it'll return attacker.atk - self.pdef / 2 OR 0, whichever is higher.

In the case that attacker.atk or self.pdef is anything but an Integer, there will be problems. MagicMagor is on the right track and if you don't honestly know the answer, Lobosque, don't post.
 

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