Jump to content

Papyrus Help: Setting a Global Variable from a Count


Recommended Posts

Hello, just adding my 2 cents. Instead of using a while loop to count, try just using intGems = Game.GetPlayer().getItemCount(1stGems)

 

According to the wiki page if passing in a form list to getItemCount, it will count how many of each item in the form list is in the container and sum it all up.

 

https://www.creationkit.com/index.php?title=GetItemCount_-_ObjectReference

 

Note I haven't tested it, and it might not work for you because you're using object references in the form list, but it's worth a shot.

Link to comment
Share on other sites

I'll also add another 2 cents.

1) Create for each gem its own 'Alias' > specific ref alias

2) In each 'Alias' run a function using the event OnContainerChange() to either:

- Increase a global variable > ModValue(), to count how many gems the player has gather.

- Or, each one to set its own variable to '1'.

- Or, both according to your needs.


Using this approach you can also assigned and distinguish the location of each gem.


* Sometimes shortcuts and compact coded functions may not do the job we want, and you may need to do a little more work to achieve the necessary goal.

In this case the 'little more work' is to assign the specific ref alias for each gem in the game's world, and not from a list.

* I for example after 12+ years of playing Skyrim, right now I don't remember the location of not a single gem in the game's world.

Edited by maxarturo
Link to comment
Share on other sites

Actually, 'OnContainerChange' will likely not work that well. The 'Unusual gem' items you see in the world are activators. On using one, it runs a script where it determines which item to add to player inventory (and what to call it depending on rellevant quest stages), after which it disables itself. And I am not yet fullly understanding why before-Vex, it apprears to just increase count of same reference - but it definitelty explains the issue OP is having, where he just gets a count of 1 gem from inventory.

Link to comment
Share on other sites

Yeah Arturos method is more or less what I would do with this too

 

To make it more compatible with other mods, you could replace the existing gem scripts with copies that use empty functions. Your quest would handle everything under the hood and you dont have to edit activators or refs this way, aka way more compatible, just make sure your override scripts dont get overridden by something else

Link to comment
Share on other sites

  • Recently Browsing   0 members

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