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.

[RESOLVED by zeh Dargor]Method to check first part of an array, like "include?"?

I have this a lot of tree charsets that all start with 05 in their filename. e.g. @character_name = "0510-BigTrees".

I need an if function that checks if the @character_name starts with 05. I know ".include?('05')" but I have files like "1250" too and that has nothing to do with the trees. ^^

Thanks in advance!
 
I think you could use
Code:
if @character_name[0,2] == "05"
It would return 2 characters, starting at index 0 (the beginning of the string). In "Hello", it would return "He"
I discovered that a few days ago and didn't had the time to test it so tell me if it works! :)

Take care!
-Dargor
 

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