Jump to content

Simple Scripting Question About ModValue


Recommended Posts

Good point I have updated my language.

 

ReloadScript is only safe for existing variable value changes or adding new variables.

 

Changing the order of existing variables or removing one will generally throw a consistency error the the log. Probaly because pointers if you know what they are.

 

Same for functions. The content of existing functions can be changed and new added, but removing functions or changing their passed parameter interfaces can also generate consistenecy errors.

 

Once a script variable or function is in a game, its there for good. I have several mods in the field with over 20 updates that have had to preserve original variables, functions and scripts even though they are demised for update in place backward compatibility. And then call for a clean when they are purged after a major restructure Example changelog.

Link to comment
Share on other sites

Thanks for the confirmation.

I hadn't considered function passed parameters as an issue since their pointers are normally constructed on-the-fly when you call that function.

Are you sure about it being an issue - especially as you can make parameters optional? As long as the calls and functions have consistent type and number of parameters of course.

 

Also what about const? Most compilers abstract constants out so they aren't part of the memory allocation/pointers. Have you had issues moving/removing const variables?

Link to comment
Share on other sites

I have had consistency errors in the log changing function calls in the same savegame which is why you need to look at the log during any changes. YMMV.

 

I only ever use CONST for properties. They will throw an inelegant log error if reassigned or removed, but does not seem to trigger pointer/stack issues:

 

warning: Property Blah on script Blah attached to (num) cannot be initialized because the script no longer contains that property

 

As I have ZERO tolerance for any of my scripts generating ANY debug log output that is not a Debug.Trace call (its a quality thing) I never dump or reassign const properties.

Link to comment
Share on other sites

 

  Reveal hidden contents

 

 

I tried it on a save from when I had no mods installed. The AVIF still didn't get changed by 50 when the function was called. I went back into CK and looked at the AVIF in the properties of the script for the quest. It still shows the property as filled but the name is shown as nullptr and the form id of the AVIF.

 

Is this normal? Is the nullptr just because my AVIF is located in a different esp?

Edited by GrimGrim31
Link to comment
Share on other sites

Holdon you seem to have changed the conditions:

 

Originally >"The actor value is in my ESP and I also declared it at the beginning of my script."

 

Now > "just because my AVIF is located in a different esp?"

 

If the form is in a different ESP then you need to make that ESP a master dependency to whatever you are working on, or use Game.GetFormFromFile(). You are entering a world of complexity you do not sound ready for.

Link to comment
Share on other sites

  On 3/10/2021 at 4:23 PM, SKK50 said:

Holdon you seem to have changed the conditions:

 

Originally >"The actor value is in my ESP and I also declared it at the beginning of my script."

 

Now > "just because my AVIF is located in a different esp?"

 

If the form is in a different ESP then you need to make that ESP a master dependency to whatever you are working on, or use Game.GetFromFromFile(). You are entering a world of complexity you do not sound ready for.

The conditions didn't change but my explanation of them was not clear enough. OK, so now I understand that the AVIF has to originate in the same ESP as the script that uses it or I have to learn a lot more about papyrus. It looks easier to just edit the two esps to relocate the AVIF along with the perks and magic spells/effects that use it.

Link to comment
Share on other sites

Thanks, the function runs correctly now that I added a line for getformfromfile.

 

Function IncreaseNPC_Friendship()
NPC_Friendship = Game.getformfromfile(0x00100D, "FriendsandEnemies.esp") as ActorValue
Game.getplayer().ModValue(NPC_Friendship, 50)
debug.notification("IncreaseNPC_Friendship Function Called")
EndFunction
I am grateful for the help. Thanks to all that replied.
I had to learn about the 0x00100D part that tells getformfromfile the form id to get. The 0x00 was new to me. I was expecting to have to put 0x64 because the FriendsandEnemies.esp is 64th in my load order.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...