Open LioMajor opened 4 years ago
This is something I'm aware of but probably won't get to for a while?
Text objects inside Calc expressions would be a real nice thing to support, but kind of requires implementing a complete expression parser, which is not exactly straightforward (but is on my long term nice to haves list)
Even for the ++
string concat operator, the calc expression can have an infinitely long chain of concats, with different combinations of variable names and string literals, function call results, etc inside the chain. And there's a ton of other expression operators and functypes that also contain translatable strings.
The lack of a real expression parser is also the main reason lmlsb edit
has to be hard coded to only support specific things.
As you already said in #60, there is currently no LNS compiler. Implementing a LNS compiler would be a very hard task. Lot of work, lot of tests, lot of bugs, lot of broken games. And where is the use case for this? Game-modding? Maybe. Game-cracking? Sometimes. Translation? No! You only need to change specific string constant fields, not the whole command. For this issue I would suggest to do something similar to lmlsb edit.
I guess you are not lucky with the kind lmlsb edit works, but it's by far the fastest way of implementation. (In terms of time it took you to implement. Not runtime performance. We are still talking about python.)
I would try to implement this, but I think it would be not in a way you have in mind.
And where is the use case for this? Game-modding? Maybe. Game-cracking? Sometimes. Translation? No! You only need to change specific string constant fields, not the whole command.
The thing is that I don't really consider pylm to be a translation tool. There's a reason that the first line in the README and the main project description is:
Python package for manipulating LiveMaker 3 game resources.
and not
Python package for translating LiveMaker 3 games.
My only real goal was to provide a usable library and API that someone else could use to write their own translation and/or patching tools.
For me, pylm is just a fun side dev/reverse engineering project. The reason I would like to write support for the full expression parser is because I can, and because I think it's a somewhat interesting problem to solve from a programming perspective :). This is the same reason issues like #45 exist, and why the code is full of commented out text/XML format LSC stubs. Originally I thought it would be very cool if pylm could take a compiled game and output a full LM project that can be opened and edited in LiveMaker itself, but haven't had time to revisit that yet.
I would try to implement this, but I think it would be not in a way you have in mind.
You are welcome to do this! Just keep in mind that depending on what you end up with, it might belong in your own github repo of "scripts that use pylm" rather than in pylm itself.
also, just to clarify, there is already an LNS compiler. calc expressions are not related to LNS scripts at all, I was just using it as a comparison to demonstrate that with regard to calc expressions.
pylm currently only supports taking the compiled binary TLiveParser
struct and converting it back into the original string calc expression, like varName = "string literal"
(via str()
). This is the equivalent of LNSDecompiler/lmlsb extract
(which decompiles a TpWord
and back into the original (or close to original) HTML-like LNS script).
pylm does not support going from the string calc expression and compiling it back into the binary TLiveParser
struct. This is the equivalent of LNSCompiler/lmlsb insert
(which takes an HTML-like LNS script and compiles it into a binary TpWord
body).
I made two scripts to extract and insert all string constants. See https://github.com/Stefan311/pylivemaker-tools @LioMajor do I need to explain how to call "loose" python scripts? @pmrowla I know this scripts do not match the pylivemaker style. So no PR this time.
extractstrings.py 000000A4.lsb 000000A4.csv Extracted 51 strings. insertstrings.py 000000A4.lsb 000000A4.csv Patching 000000A4.lsb ... Backing up original LSB. Wrote new LSB. @Stefan311 works well, many thanks.
@pmrowla did you notice that there text exists to translate that's not handled by extract, extractcsv or extractmenu?
Example: C:\test>lmlsb dump 00000019.lsb -o 00000019.txt
1258: Label 0000365F 1259: If 操作キャラ == 1 1261: Calc 顔番号 = 13 1262: Call 00000CA4.lsb:6 1 1263: If 選択番号 == 18 1264: Calc 文字列a = ヒロイン名前 ++ " 「It's too late today, let's stop...」" 1265: Else 1266: Calc 文字列a = ヒロイン名前 ++ " 「It's already late today and i don't have time to work.」" 1267: Elseif 操作キャラ == 2 1269: Calc 顔番号 = 6 1270: Call 00000CA4.lsb:6 1 1271: Calc 文字列a = ロリ名前 ++ " 「Oh, it's late. I'm going to continue tomorrow.」" 1272: Else 1273: Calc 文字列a = ビッチ名前 ++ " 「It's already late. You should continue tomorrow.」" 1274: Jump 00000019.lsb:1007 1
So far, the only way to edit the text is:
C:\test>lmlsb edit 00000019.lsb 1264 1264: Calc 文字列a = ヒロイン名前 ++ " 「It's too late today, let's stop...」"
Editing Calc expression 文字列a = ヒロイン名前 ++ " 「It's too late today, let's stop...」" Skipping uneditable parser entry: ヒロイン名前 ++ ____0 Destination variable [文字列a]:
00000019.zip