Jump to content

Recommended Posts

I would like to use papyrusutil for a mod I am working on, but I am not going to add it as a dependency if it is only available for download on LL. In the interest of wider adoption and standardization, please maintain a nexus page.

I also get asked this on nexus several times.

 

Ashal do you think you could maintain this on nexus or a separate git page or something so normal users can download easily?

Link to comment

Does the startIndex parameter on the slice functions determine the starting point in the papyrusutil list or the start index in the array to copy the items into?

 

I'm assuming it's the index in the papyrusutil list. Which also means I need to do a bit extra to merge couple of lists.

Link to comment

Does the startIndex parameter on the slice functions determine the starting point in the papyrusutil list or the start index in the array to copy the items into?

The papyrusutil list.

 

The array will be filled until either the list or array run out indexes from that starting point.

Link to comment
Next version I've also added a Int/FloatListAdjust() and AdjustInt/FloatValue() function for adjusting list indexes and single value by a given amount. Basically a single function that would do the same as calling "SetIntValue(form, "key", (GetIntValue(form, "key") + 10))" as simply "AdjustIntValue(form, "key", 10)"

 

Link to comment

I am not sure if I am missing something but why was ImportFile/ExportFile removed from StorageUtil? Is there a chance it will come back?

 

The way file storage works now is completely different than before. Previously file storage existed only as a way to export/import current StorageUtil values to/from the external files. Which was rather slow and made it harder to work with.

 

Import/ExportFile has basically been replaced by the new JsonUtil script which lets you manipulate the external files from their own storage using all the same functions as StorageUtil, which is faster and allows you to manipulate the file data at will while maintaining separate sets of data.

Link to comment

Here is a test release of the next release.

 

<attachment removed>

 

 I could use a couple confirmations from testers that nothing is broken before I throw it up for official release.

 
 

Changelog: 

  • Added back package override saving - this should restore functionality of the "I'll take the display model" mod.
  • Added AdjustInt/FloatValue() and Int/FloatListAdjust() functions to StorageUtil and JsonUtil, shortcut function for adjusting existing values +/- a given amount
  • Added a ClearAll() function to JsonUtil for emptying out an external json files contents.
  • Cleaned up various native functions to better check for proper arguments being passed to prevent potential crashes.
Link to comment
  • 3 weeks later...

There is a serious bug in PapyrusUtil 2.7 which is not in an older version of PapyrusUtil (We used version 2.2).

Given this code:
 

Function ChangeModPriority(String asModName, Int aiPositionChange)
	Int ModIndex = StorageUtil.StringListFind(None, SUKEY_REGISTERED_MODS, asModName)
	Form QuestToken = StorageUtil.FormListGet(None, SUKEY_REGISTERED_MODS, ModIndex)

	ShowMessage("Index: " + ModIndex + "\nQuest: " + (QuestToken As Quest).GetName(), False)

	If(aiPositionChange == MOVE_TOP)
		If(ModIndex == (StorageUtil.StringListCount(None, SUKEY_REGISTERED_MODS) - 1))
			Return
		EndIf

		StorageUtil.FormListRemove(None, SUKEY_REGISTERED_MODS, QuestToken)
		StorageUtil.FormListAdd(None, SUKEY_REGISTERED_MODS, QuestToken)
		
		StorageUtil.StringListRemove(None, SUKEY_REGISTERED_MODS, asModName)
		StorageUtil.StringListAdd(None, SUKEY_REGISTERED_MODS, asModName)
	ElseIf(aiPositionChange == MOVE_UP)
		If(ModIndex == (StorageUtil.StringListCount(None, SUKEY_REGISTERED_MODS) - 1))
			Return
		EndIf
		
		If(ModIndex == (StorageUtil.StringListCount(None, SUKEY_REGISTERED_MODS) - 2)) ;this is equivalent to MOVE_TOP
		
			StorageUtil.FormListRemove(None, SUKEY_REGISTERED_MODS, QuestToken)
			StorageUtil.FormListAdd(None, SUKEY_REGISTERED_MODS, QuestToken)
			
			StorageUtil.StringListRemove(None, SUKEY_REGISTERED_MODS, asModName)
			StorageUtil.StringListAdd(None, SUKEY_REGISTERED_MODS, asModName)			
		Else
			StorageUtil.FormListRemove(None, SUKEY_REGISTERED_MODS, QuestToken)
			StorageUtil.FormListInsert(None, SUKEY_REGISTERED_MODS, (ModIndex + 1), QuestToken)
			
			StorageUtil.StringListRemove(None, SUKEY_REGISTERED_MODS, asModName)
			StorageUtil.StringListInsert(None, SUKEY_REGISTERED_MODS, (ModIndex + 1), asModName)
		EndIf
	ElseIf(aiPositionChange == MOVE_DOWN)
		If(ModIndex == 0)
			Return
		EndIf
		
		StorageUtil.FormListRemove(None, SUKEY_REGISTERED_MODS, QuestToken)
		StorageUtil.FormListInsert(None, SUKEY_REGISTERED_MODS, (ModIndex - 1), QuestToken)
		
		StorageUtil.StringListRemove(None, SUKEY_REGISTERED_MODS, asModName)
		StorageUtil.StringListInsert(None, SUKEY_REGISTERED_MODS, (ModIndex - 1), asModName)
	ElseIf(aiPositionChange == MOVE_BOTTOM)
		If(ModIndex == 0)
			Return
		EndIf
		
		StorageUtil.FormListRemove(None, SUKEY_REGISTERED_MODS, QuestToken)
		StorageUtil.FormListInsert(None, SUKEY_REGISTERED_MODS, 0, QuestToken)
		
		StorageUtil.StringListRemove(None, SUKEY_REGISTERED_MODS, asModName)
		StorageUtil.StringListInsert(None, SUKEY_REGISTERED_MODS, 0, asModName)
	EndIf
EndFunction

The array will be displayed in reverse order of how the elements are stored internally. So MOVE_TOP would put the element at the end of the array, MOVE_BOTTOM will put the element at the top of the array. Same behavior applies to MOVE_UP and MOVE_DOWN.

 

Now with PapyrusUtil 2.2 everything works as expected. Every command will place the selected element at the expected position. Now with PapyrusUtil 2.7 there is a serious error. No matter of which command, the array looks totally messed up after using them.

 

Without knowing the source code, I believe there is some logical error in how the Remove(), RemoveAt() and Insert() functions working. I assume they do not properly move the elements in the array when an element is removed and/or inserted.

 

Edit: Added screenshots so you can get a picture of what happens to the array

 

Initial situation:

post-222463-0-43872500-1411990931_thumb.jpg

Moving first element of the array to the last position (Remember, they are displayed in reverse order)

post-222463-0-92500700-1411990934_thumb.jpg

How the array looks like after calling the function

post-222463-0-14921300-1411990938_thumb.jpg

 

 

Just another edit:

 

This is the code which displays the array in the MCM

 

 

Event OnPageReset(String asPage)
    StorageUtil.IntListClear(None, SUKEY_MENU_OPTIONS)
    StorageUtil.StringListClear(None, SUKEY_MENU_OPTIONS)

    If(asPage == Pages[0])
        SetCursorFillMode(TOP_TO_BOTTOM)
        AddHeaderOption("Registered mods")
        AddEmptyOption()
        
        Int RegisteredMods = StorageUtil.FormListCount(None, SUKEY_REGISTERED_MODS)
        Int i = RegisteredMods
        
        ;SUKEY_REGISTERED_MODS: [3, 2, 1]
        While(i > 0)
            StorageUtil.IntListAdd(None, SUKEY_MENU_OPTIONS, AddMenuOption(StorageUtil.StringListGet(None, SUKEY_REGISTERED_MODS, i - 1), "#" + (RegisteredMods + 1 - i) As String + ": ")) ;IntSUKEY_MENU_OPTIONS: [1, 2, 3]
            StorageUtil.StringListAdd(None, SUKEY_MENU_OPTIONS, StorageUtil.StringListGet(None, SUKEY_REGISTERED_MODS, i - 1)) ;StringSUKEY_MENU_OPTIONS: [1, 2, 3]
            i -= 1
        EndWhile
    EndIf
EndEvent
Link to comment

2.7 has a logic error that basically makes it do the opposite of what you want with string lists. I'm already aware and have fixed it for the next version.  Just trying to fix a few other issues as well before release.

Link to comment
2.8 - 10/03/2014

  • Fixed critical bug causing StringListRemove to do exactly the opposite of what you want it to do

  • Fixed crash to desktop issue some users have experienced when plugin loads an external json files for reading

  • Added papyrus array initializing functions to PapyrusUtil.psc

Link to comment

For info, V2.8 is causing a ctd when a rusty chastity belt is fitted by Draugr in Deviously Helpless (similar issue to v2.3 iirc). I've sent logs to Srende to have a look at the problem

 

The issue wasn't with the belt, but a RemoveAllPackageOverride() call done around the same time. I've no idea if the issue here is even related, I'll check it later.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use