Checking whether a file exists

Glidergun

Chieftain
Joined
Oct 26, 2014
Messages
59
I would like my mod to fail gracefully when combined with other mods. As it alters some icons by rerouting their references to other images I have created, the easiest way for me to do this is to first check if the file I am trying to reroute to exists. Unfortunately, I'm only really enough of a programmer to do the cargo-cult thing and copy snippets I've already seen.

Is there any way to check whether or not [arbitraryfilename].[ext] is a thing that exists using Lua?
 
I'm not very familiar with Lua yet, but I'm sure if you make an if statement you should be able to detect if the file is present and if so either update it and your own or delete it.
 
You don't have access to the filesystem, but you can check whether a particular change is made to the database, or even whether a mod with a given mod id is active.

The easiest way is to use the References/Blocks/Dependencies system [in the mod properties]. As cool as that method is, note there is an issue with VFS order.
 
Top Bottom