Jump to content
Koregan

getFileWriter - relative / direct path (b32.3)

Recommended Posts

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 ... to

write 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\m
ods\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\ ?

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

'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?

Share this post


Link to post
Share on other sites

 

'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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...