Jump to content
Narrnika

Lua - bad reading/writing of files

Recommended Posts

When using functions getFileReader, getFileWriter, getModFileReader, getModFileWriter in lua, national (no-ascii) characters are lost (more precisely, they turn into question marks when writing and into an unprintable character when reading). In the original game (without mods) this is manifested when saving/loading character settings or sandbox settings:

screen1.thumb.png.4479f72b00293db97e8f49620108b3f4.png

 

screen2.thumb.png.42a7cb5e913a8675fa9f85ac35cbf6ad.png

 

Try to read a corrected file:

screen3.thumb.png.ad70de5c04b6f60ab42f96df6dd06ece.png

 

It is not very critical in this particular place, but sometimes creates problems in mods (both when writing and when using).

 

In this regard, the suggestion: if the files are badly read from lua, then read them in java, and transfer a table of strings to lua. And vice versa - transfer to functions a table with strings, which will be written to the file in Java. That is, add something like this:

// in addition to getFileReader()
@LuaMethod(name = "ReadFileToTable", global = true)
public static KahluaTable ReadFileToTable(String param1String, boolean param1Boolean) {
	...
}

// in addition to getModFileReader()
@LuaMethod(name = "ReadModFileToTable", global = true)
public static KahluaTable ReadModFileToTable(String param1String1, String param1String2, boolean param1Boolean) {
	...
}

// in addition to getFileWriter()
@LuaMethod(name = "WriteTableToFile", global = true)
public static void WriteTableToFile(KahluaTable param1KahluaTable, String param1String, boolean param1Boolean1, boolean param1Boolean2) {
	...
}

// in addition to getModFileWriter()
@LuaMethod(name = "WriteTableToModFile", global = true)
public static void WriteTableToModFile(KahluaTable param1KahluaTable, String param1String1, String param1String2, boolean param1Boolean1, boolean param1Boolean2) {
	...
}

 

 

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