Koregan Posted May 30, 2015 Posted May 30, 2015 I have problems using getFileWriter() in build 32(.3): Relative paths are forebidden now, so I have to change to direct paths.Before this build, I used ".."..File.separator.."mods"..File.separator ... towrite a file in my ModData-Subdirectory of my ModDirectory. But now, if I give the whole direct path with Core.getMyDocumentFolder()..File.separator .."mods"..File.separator.."KoregansServerMod"..File.separator.."ModData"I get errors, because the local path C:\Users\Andi\Zomboid\Lua\ is standing in front of my direct path. ERROR in console:java.io.FileNotFoundException: C:\Users\Andi\Zomboid\Lua\C:\Users\Andi\Zomboid\mods\KoregansServerMod\ModData\Playerlist\11-58-58_PlayerList.txt (Die Syntax f³r den Dateinamen, Verzeichnisnamen oder die Datentrõgerbezeichnung ist falsch) Is there a way to set files in my moddirectory instead of zomboid\lua\ ?
Dr_Cox1911 Posted May 30, 2015 Posted May 30, 2015 AFAIK no, you can only write/read files from Zomboid\lua (for security reasons I suppose).
Koregan Posted May 30, 2015 Author Posted May 30, 2015 But I think there should be access to your own moddirectory. (In the version before (b31), my mod was able to create files in my moddirectory and chatlogs in "Zomboid\Multiplayer".) So if the "local path" would be changed to "Zomboid" instead of "Zomboid\Lua"then it would be also sure that no files outside would be changed.
Brybry Posted May 31, 2015 Posted May 31, 2015 You want getModFileWriter(String modId, String filename, boolean createIfNull, boolean append)not getFileWriter.
Koregan Posted May 31, 2015 Author Posted May 31, 2015 Thank you Brybry for this information. Didn't know this way or function. For all modders which have / had the same problems a short explaination of getModFileWriter getModFileWriter(String modId, String filename, boolean createIfNull, boolean append ) modId has to be the id of your mod (written as in mod.info), then the file "filename" will be written direct in your moddirectory.
Brybry Posted May 31, 2015 Posted May 31, 2015 'filename' can be a path too so you aren't limited to writing in the root of your mod directory (ex. 'media/lua/foobar.txt')
ethanwdp Posted July 1, 2015 Posted July 1, 2015 'filename' can be a path too so you aren't limited to writing in the root of your mod directory (ex. 'media/lua/foobar.txt')Is getModFileWriter present in both Build 31 and 32, or is it a new Build 32 feature?
Brybry Posted July 2, 2015 Posted July 2, 2015 'filename' can be a path too so you aren't limited to writing in the root of your mod directory (ex. 'media/lua/foobar.txt')Is getModFileWriter present in both Build 31 and 32, or is it a new Build 32 feature? It's in both. It's actually been around since before build 28. ethanwdp 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now