Jump to content

Lua - bad reading/writing of files


Narrnika

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) {
	...
}

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...