Open mrowrpurr opened 2 years ago
I tried outputting the latest version of PapyrusUtil and had the same issue in a few places, e.g.
export const JsonExists = (FileName: string): boolean => sn.JsonExists(FileName)
if !FileName
return false
elseIf StringUtil.Find(FileName, ".json") == -1
FileName += ".json"
endIf
return MiscUtil.FileExists("data/skse/plugins/StorageUtilData/"+FileName)
endFunction
And then in some places I get a weird mix of TypeScript and Papyrus, e.g.
// ## Similar to SKSE's native StringUtil.Split() except results are whitespace trimmed. So comma, separated,list,can, be, spaced,or,not.
export const StringSplit = (// string ArgString, string Delimiter = ","): string[] => sn.StringSplit(ArgString, Delimiter, ")
// ## Opposite of StringSplit()
export const StringJoin = (// string[] Values, string Delimiter = ","): string => sn.StringJoin(Values, Delimiter, ")
Yes.
This only translates function headers, not function bodies. Everything that is not a function header gets exported as is; in this case, plain Papyrus code.
PapyrusUtil was particularly hard and annoying to translate because of that.
Doing full translation from Papyrus to Typescript is way beyond what I'm willing to do xD. I would need to parse, tokenize and whatnot.
Too much work.
In fact, I had to manually translate all functions you listed.
And then in some places I get a weird mix of TypeScript and Papyrus, e.g.
// ## Similar to SKSE's native StringUtil.Split() except results are whitespace trimmed. So comma, separated,list,can, be, spaced,or,not. export const StringSplit = (// string ArgString, string Delimiter = ","): string[] => sn.StringSplit(ArgString, Delimiter, ") // ## Opposite of StringSplit() export const StringJoin = (// string[] Values, string Delimiter = ","): string => sn.StringJoin(Values, Delimiter, ")
The new version I'm working on already deals with this sucessfully. Hope to be able to release around these days.
I tried outputting the latest version of PapyrusUtil and had the same issue in a few places, e.g.
export const JsonExists = (FileName: string): boolean => sn.JsonExists(FileName) if !FileName return false elseIf StringUtil.Find(FileName, ".json") == -1 FileName += ".json" endIf return MiscUtil.FileExists("data/skse/plugins/StorageUtilData/"+FileName) endFunction
In the new version I added a mode to patch those kind of things once they have been manually translated. It deals with this function in particular and many others thanks to a json config file.
When I ran the generator for JContainers 4.2.1, the JContainers.ts file included some Papyrus
Here is the relevant output:
Here is the relevant error I got: