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.

FileTest.Exist

Hello.

Well, I am needing to check if the file (x) exists, so I use the function:

if FileTest.exist?("Graphics/Pictures/" + $fileName)

Well, that way work. But if I encript the game, it won't work. So, I try this:

if FileTest.exist?(RPG::Cache.picture($fileName))

But this way doesn't work. I get the error message: "Cannot convert bitmap into string". I already tryed .to_s, but it didn't work...
Anyone knows how can I check using the module?

Thanks from now,
see ya.
 
A begin/rescue block will do the trick here.

Code:
begin
  # test if a the file can be loaded
  RPG::Cache.picture($fileName)
  # do stuff here
rescue Errno::ENOENT
  # file does not exsist
end
 

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