Michael-wigontherun / ESLifyEverything

https://www.nexusmods.com/skyrimspecialedition/mods/75248
27 stars 3 forks source link

Sometimes decompiled scripts won't compile because of a lack of a default value on variable declarations in function parameters. #11

Closed Morribyte closed 1 year ago

Morribyte commented 1 year ago

Papyrus source scripts have default values attached to their variable. However, when you decompile them their default values are wiped away. For example, instead of bool NameOfVar = false it'll just say Bool NameOfVar. For whatever fucking reason, the compiler really hates it sometimes when scripts don't have default values attached to function parameters. I haven't really pored too much over scripts but I've noticed that it seems kind of inconsistent in whether or not it'll compile without the default value or not.

Then you often have to go through and re-add in the default values just to get the new scripts to compile, taking a ton of time to fix because you often have to hunt down whatever script that the function originated in. This is especially a problem in sexlab mods where there's a ton of interfunctionality on top of the usual cross-script function calls:

image

I've mostly noticed this happen with Bool, Int, Float, and Strings. Very rarely with Objects or Arrays.

I'm honestly not sure how feasible this is, but I figured I'd ask anyway just in case it's something that's doable without a lot of effort: can you see about having ESLify Everything re-add in the default values for variables in the decompilation stage? i wouldnt even know how to go about that...

https://ck.uesp.net/wiki/Default_Value_Reference

Michael-wigontherun commented 1 year ago

Was that a script that had a form key changed or was it a script needed by a script that had a form key changed?

Morribyte commented 1 year ago

Was that a script that had a form key changed or was it a script needed by a script that had a form key changed?

It's been an issue in both types of scripts. I've had to go through and re-add values on any script that's both been needed or been changed.

Michael-wigontherun commented 1 year ago

Do you have any non loverslab mods that have this issue?

Michael-wigontherun commented 1 year ago

Try this Pre-Release: https://github.com/Michael-wigontherun/ESLifyEverything/releases/tag/P4.3.2

And tell me if I didn't cover everything that was needed.

Morribyte commented 1 year ago

Do you have any non loverslab mods that have this issue?

Yeah, I have had non-loverslab mods have the issue. Any mod that would need a decompiled SkyUI script such as a MCM would have the issue for example.

And thanks, I'll give it a shot right now!

Morribyte commented 1 year ago

Okay, so it worked for most of the scripts I tested (yay!) except one which I think is due to it being written a bit weirdly.

RaceMenu undress has a script in it called racemenuundress (lol, creative) that has a weird string declaration with a function right after. It gave me these errors until I deleted the = "" at which point it compiled properly.

image

image

Here's the nexus page for racemenu undress so you can investigate it if there's more information that I wasn't able to provide:

https://www.nexusmods.com/skyrimspecialedition/mods/56437

Morribyte commented 1 year ago

Sorry, I didn't realize I didn't catch the line numbers in the screenshot. Line 11 is the "String property CALLBACK_PART" part. The "fixed" script had a = "" at the end, but it wouldn't compile until i took it off.

Michael-wigontherun commented 1 year ago

See if this fixes the issue: https://github.com/Michael-wigontherun/ESLifyEverything/releases/tag/P4.3.3

Morribyte commented 1 year ago

Sweet, it worked this time. I will keep testing it and seeing if any scripts refuse to compile. Thanks!

Morribyte commented 1 year ago

Ok, it does look like some scripts were missed out on.

Looks like one is StringUtil from SKSE's scripts, one from Game.psc in SKSE's scripts and one is debug.psc from Skyrim's BSA.

One thing I noticed in common with all of the scripts that were missed is that they didn't have variables declared at the start:

image

So I guess there might be cases where if there's no variable declarations at the start, they might need to be filled out (or added or something)?

Morribyte commented 1 year ago

Yeah, I don't understand it but changing the lines in the functions for the variable to say:

int function GetLength(String S = "") global native lets it compile (as long as I've fixed all the variables the compilation calls).

I was NOT able to make it work by putting a variable declaration in the top of the script. I guess sometimes, functions don't need express variable declarations as long as their default values are stated within a function parameter? or something. So, I guess in some cases, if a function is called cross-script the variable's default value needs to be declared within the function. I guess?

Michael-wigontherun commented 1 year ago

Functions should not have default values unless it was meant to have default values. Global variables are not needed for scripts to work its just a global access for when multiple things need to have that object and you don't want to pass it through every function.

I think you should reinstall your Creation kit something is wrong on that end.

Michael-wigontherun commented 1 year ago

It could also be you don't have the correct versions of things that error you posted at the top meant the function does not exist. Meaning a function its calling is missing from the import. Which should only be the case if what ever function it originated from was updated or backdated removing the outdated scripts functionality.

I will not let ESLify Everything mess with the actual logic of things.

Morribyte commented 1 year ago

I've already reinstalled my CK and Skyrim thinking that might be the issue, sadly it still persists. I'll see if I can explain it a little better...

SLSF_Utility had a FormID change and was output by ESLify everything. When I tried to recompile it, these errors popped out:

image

So, I went to the script which calls a function in SLSFUtility called Fix Range Value

image

Here is the function for that. As you can see, there are no default values here and this lines up with what the papyrus compiler is popping out.

image

In the original script...

image

I mean obviously in this case I wouldn't have needed to edit default values since there were non-default values here (specifically on the variable named max) but there were other scripts wherein I needed to in order to get them to compile. An example being...

From a SexLab Adventures function...

From the source script...

image

From the ESLify'd script...

image

what the compiler says...

image

It seems like, for at least those functions I'll probably need to go through by hand and fix them huh? since it'd be impossible to know what values the original script is going for.

...although, I'll note that I'm using Papyrus Compiler App. I guess I can try to compile it without it but since PCA uses the Papyrus Compiler from the Skyrim directory I can't see how it'd make a difference.

Michael-wigontherun commented 1 year ago

And I am still telling you one or the other is out of date, you cant just add a default value for it and say now its fixed. The mods logic is outdated because the API was changed. Adding a default value to fix the issue is not something I will do. Manipulating the logic of things when you have no way to know what or how it will edit other things is not something is ok to do.

Changing the FormID that was changed is just necessary. Adding a initialization to a global value is nothing at all. But changing how scripts work by using a program instead of a human looking and can tell what needs fixing and what doesn't to do so is a recipe for disaster.

I will not script adding defaults to function parameters.

Morribyte commented 1 year ago

Right, makes sense -- if it really is an issue of what's out of date then I'll go digging and make sure that everything I have is up-to-date.

I guess I just wasn't sure because of the fact that mods like SkyUI and UIExtensions have values on their function parameters in the source files, which I know for sure I have up-to-date versions.

Thank you though! I'll at least keep double-checking that the other scripts work correctly.