Jump to content

Recommended Posts

Posted

I see your point.

I did not pay attention that the two inits, also if they have the same ID, they are NOT being executed at the same time.

 

Now, I never use StorageUtil for global values, I use it for values attached to a specific Form.

I don't know if it is a good idea to use StorageUtil for global values, usually I use JsonUtil for that.

 

Posted

But JsonUtils values are global even between different game starts. I want a global list within one game only.

 

I have used StorageUtil for inter mod data transfer (foreign mods provides resources that are used by the main mod) - but since some versions (I did not notice the last working version) it is no longer possible because the data is initialized more than once.

 

This is a pity - but the magical disappearance of objects in formlists is a showstopper - it is unpredictable which data can be stored without loss in StorageUtil containers. I checked the lifeline of my FormIDs ten times and traced my mod until it hobbles - only StorageUtil is affected - and the same code has worked some time ago.

 

To bad that my mod is based so much on StorageUtils...

Posted

I am looking for some help in setting up a list where I can make a rotating list of sorts. Basically I want to process the oldest item on the list (an actor) then remove them from the list while other parts add new actors to the list. I had intended on using a formlist but the command to remove an added form does not work. I have been looking at the StorageUtil.psc file trying to figure out the commands to use but I am having trouble figuring it out.

 

I think that I would use 'SetFormValue' to add the actor to the list.

Then I think I would use 'FormListShift' to get the first actor and remove them from the list.

It also looks like I would use 'FormListCount' to get the size of the list so I can check to see if I have anyone on the list.

 

Is there anything I am missing? Am I headed in the right direction or am I not even close? I want to get an Idea if I am right before I start rewriting the scripts.

Posted

I am looking for some help in setting up a list where I can make a rotating list of sorts. Basically I want to process the oldest item on the list (an actor) then remove them from the list while other parts add new actors to the list. I had intended on using a formlist but the command to remove an added form does not work. I have been looking at the StorageUtil.psc file trying to figure out the commands to use but I am having trouble figuring it out.

 

I think that I would use 'SetFormValue' to add the actor to the list.

Then I think I would use 'FormListShift' to get the first actor and remove them from the list.

It also looks like I would use 'FormListCount' to get the size of the list so I can check to see if I have anyone on the list.

 

Is there anything I am missing? Am I headed in the right direction or am I not even close? I want to get an Idea if I am right before I start rewriting the scripts.

 

You're close, it should be FormListAdd(), not SetFormValue().

 

I'd do something like this:

 

bool function AddActorToList(Actor ActorRef)
   if ActorRef && !StorageUtil.FormListHas(self, "MyList", ActorRef)
      Storageutil.FormListAdd(self, "MyList", ActorRef, false)
      return true ; // Actor is now added to end of list.
   endIf
   return false ; // Actor was already in the list, ignore them.
endFunction

Actor function GetActorInList()
   while StorageUtil.FormListCount(self, "MyList") > 0
      ; // Get and remove the first item in the list
      Form FormRef = StorageUtil.FormListShift(self, "MyList")
      ; // Make sure they are an actor type still.
      ; // If they were a temporary object (like a bandit) they might have been deleted.
      if FormRef && (FormRef.GetType() == 43 || FormRef.GetType() == 44 || FormRef.GetType() == 62)
         return FormRef as Actor ; // Return the actor as a form.
      endIf
   endWhile
   return none
endFunction

Then whenever you want to process the oldest actor in the list, do something like this:

bool function PerformActionOnOldest()
   Actor ActorRef = GetOldestActorInList()
   if ActorRef

      ; // perform actions on ActorRef

      return true
   endIf
   return false
endFunction
Posted

i actually ran into zaira's OnInit problem a long long time ago. i'm trying to recall out what project it was. but basically yeah, if you attempt to access too soon on game start it doesn't work. i think at the time i was trying to read something out during MCM's OnGameReload event.


 

an actor is added to the form list every time the spell is cast, there are six actors in my form list in my save game. the data is apparently not yet accessible at OnGameReload, yet it is accessible 4 seconds later by the time i open up the mcm menu.

 

  1. rebuild mod
  2. start new game
  3. cast on six actors
  4. save game
  5. load game
  6. OnGameReload() - empty data set.
  7. whatever skyrim does between that and giving me game control
  8. OnConfigOpen - data set available.

 

 

looks like it was the old display model, a year and a half ago. i was being a jerk about it, too. this was back when ai package overrides weren't saved for a version and i was trying to come up with a way to rebind the actors before you re-added override saving.

 

so yeah, it's def a thing.

 

there is probably a better way to do what zar is trying to do. since then none of my mods have run into that issue because setting up in that manner has not been required nor preferable to me. but without context of what they are doing not sure.

 

as for the lost forms, nope. untamed, display model 2, and soulgem oven would have instantly imploded if forms were getting lost. throwing them in storageutil is not a magic persist machine (nor should it be), but again i have no context.

Posted

 OnGameReload, FormListCount is returning 0. Later after the game is established, it returns the actual count.

Event OnGameReload()
	parent.OnGameReload()
	Debug.Trace("DISPLAY MODEL GAME LOAD")
	DM.FixBoundActors()
EndEvent
Function FixBoundActors()
	;; as of papyrusutil 2.5+/sexlab 1.59 ai packages are no longer
	;; reapplied magically on game load.

	Int a = 0
	Int len = FormListCount(self,"dcdm_BoundActors")
	Actor who

	Debug.Trace(len + " actors marked as willbound.")

	While a < len
		who = FormListGet(self,"dcdm_BoundActors",a) as Actor
		Debug.Trace("Applying Display Model Packages to " + GetActorName(who))
		BehaviourLockdown(who)
		BehaviourReapply(who)
		a += 1
	EndWhile

	Return
EndFunction

[08/20/2014 - 02:05:25AM] DISPLAY MODEL GAME LOAD

[08/20/2014 - 02:05:25AM] 0 actors marked as willbound.
 
then later my mcm lists all the actors in the list.
 
Function ShowPageBound()
	SetTitleText("Will Bound Actors")

	Int a = 0
	Int len = FormListCount(DM,"dcdm_BoundActors")
	Actor who

	While a < len
		who = FormListGet(DM,"dcdm_BoundActors",a) as Actor
		AddToggleOption(DM.GetActorName(who),True)
		a += 1
	EndWhile

	Return
EndFunction

and this works just fine.

 

i've tried with both None and the Quest Controller as the target of FormList* functions (these copy pastes using the quest controller. i used None first.). same result. data not available yet, i assume.

 

so...?

 

Posted

Easy question but really important..

 

Should i overwrite Sexlab files with papirus util files or not?

 

Doesn't matter, so long as you are using an up to date version of SexLab they are the exact same files. The version included with SexLab will always be the latest version of PapyrusUtil.

Posted

 

Easy question but really important..

 

Should i overwrite Sexlab files with papirus util files or not?

 

Doesn't matter, so long as you are using an up to date version of SexLab they are the exact same files. The version included with SexLab will always be the latest version of PapyrusUtil.

 

 

 

ty a lot :D

  • 4 weeks later...
Posted

Sorry for asking an amateur question but i couldn't find the answer myself.

 

PapyrusUtil is a requirement for a mod i intend to use (Private Needs Discreet).

 

I'm still using SexLab 1.59c and i would like to know wich version of PapyrusUtil i'll have to download for it to be compatible with that particular version of SexLab

 

Thanks in advance.

Posted

Sorry for asking an amateur question but i couldn't find the answer myself.

 

PapyrusUtil is a requirement for a mod i intend to use (Private Needs Discreet).

 

I'm still using SexLab 1.59c and i would like to know wich version of PapyrusUtil i'll have to download for it to be compatible with that particular version of SexLab

 

Thanks in advance.

 

All papyrus util versions are compatible with each other.

 

Now, please upgrade to the latest version of SexLab. You will do a favor to yourself.

For papyrusutil alone, always grab the latest version.

Posted

 

Sorry for asking an amateur question but i couldn't find the answer myself.

 

PapyrusUtil is a requirement for a mod i intend to use (Private Needs Discreet).

 

I'm still using SexLab 1.59c and i would like to know wich version of PapyrusUtil i'll have to download for it to be compatible with that particular version of SexLab

 

Thanks in advance.

 

All papyrus util versions are compatible with each other.

 

Now, please upgrade to the latest version of SexLab. You will do a favor to yourself.

For papyrusutil alone, always grab the latest version.

 

Thank you kindly for your quick reply. :)

 

I had no idea 1.59c was no longer supported, i wil take a look at the latest version then.

  • 2 weeks later...
  • 4 weeks later...
Posted

Hello Ashal,

 

congrats for the new "path oriented" function to handle JSON files.

 

Now, I think there is a potential problem with the case sensitivity.

The non-path-oriented function were always putting lowercase the keys, and when you get a value, it does not matter the case of the string, it is searched lowercase.

 

For the path-oriented functions, it seems that you are storing the keys in the exact case you get them from Papyrus.

But this can be problematic.

 

Case you search for keys in paths by doing a not-case-sensitive comparison: it will work, but of course it consumes a little bit more computing power that a case-sensitive comparison.

Case you search keys in paths as is: then some keys will not be found, because the case of a string in Papyrus may change depending on the installed mods.

 

 

K.R.,

  • 3 weeks later...
Posted

Documentation request: on the PapyrusUtil.StringSplit, function inform people that, in case the string is empty, they will still get an array, of size 1, and with an empty string inside.

StringUtil.split, in case of an empty string, returns a StringArray of size zero.

 

So a direct replacement may not work.

 

  • 4 weeks later...
Posted

is there a way to add logic to json strings to run Actor.GetLeveledActorBase().GetName() when string is loaded/displayed by script

JsonUtil.StringListAdd("file", "key", "string1" + Actor.GetLeveledActorBase().GetName() + "string2", false)

or only splitting into 2 strings and then mergin with

notification/ messagebox(json string1 + Actor.GetLeveledActorBase().GetName() + json string2)

?

Posted

is there a way to add logic to json strings to run Actor.GetLeveledActorBase().GetName() when string is loaded/displayed by script

JsonUtil.StringListAdd("file", "key", "string1" + Actor.GetLeveledActorBase().GetName() + "string2", false)

or only splitting into 2 strings and then mergin with

notification/ messagebox(json string1 + Actor.GetLeveledActorBase().GetName() + json string2)

?

 

You have to do it in your code.

Not everybody will want this behavior, and it is not at PapyrusUtil level to understand that you want the name of the actor base or the displayname of the actual actor.

Posted

 

is there a way to add logic to json strings to run Actor.GetLeveledActorBase().GetName() when string is loaded/displayed by script

JsonUtil.StringListAdd("file", "key", "string1" + Actor.GetLeveledActorBase().GetName() + "string2", false)
or only splitting into 2 strings and then mergin with

notification/ messagebox(json string1 + Actor.GetLeveledActorBase().GetName() + json string2)
?

 

 

You have to do it in your code.

Not everybody will want this behavior, and it is not at PapyrusUtil level to understand that you want the name of the actor base or the displayname of the actual actor.

 

And i guess there is no function/special signs to replace placeholder text with actor name/any other text?
Posted

And i guess there is no function/special signs to replace placeholder text with actor name/any other text?

 

Not in PapyrusUtil.

The best you can do is to use the SKSE StringUtil functions.

 

Something like:

 

 

String aTestString = "Here goes %s1 for the fun of everybody."
 
String Function formatString(String src, Sttring part)
  int pos = StringUtil.find(src, "%s1")
  if pos==-1
    return src
  endIf
  return StringUtil.substring(src, 0, pos) + part + StringUtil.substring(src, pos+3)
EndFunction
 
Event OnInit()
  Debug.trace(formatString(aTestString, Game.getPlayer().getDisplayName()))
EndEvent

 

Posted

 

And i guess there is no function/special signs to replace placeholder text with actor name/any other text?

 

Not in PapyrusUtil.

The best you can do is to use the SKSE StringUtil functions.

 

Something like:

String aTestString = "Here goes %s1 for the fun of everybody."
 
String Function formatString(String src, Sttring part)
  int pos = StringUtil.find(src, "%s1")
  if pos==-1
    return src
  endIf
  return StringUtil.substring(src, 0, pos) + part + StringUtil.substring(src, pos+3)
EndFunction
 
Event OnInit()
  Debug.trace(formatString(aTestString, Game.getPlayer().getDisplayName()))
EndEvent

tought so, thx

Posted

I have questions about ActorUtil:

 

Does a package override remains forever or is it removed when the packages has finished (single run package)?

 

Can I add more than one package override to an Actor - eg. a Travel package prio 100 and a Sandbox Package prio 100 and is my second package called when the Travel package has finished (considering there are no other packages) (package sequence)?

 

Is it valid to call RemovePackageOverride(self) from package end fragment (creating single run packages)?

 

What is the parameter flags in AddPackageOverride for?

Posted

You can add more than one. Higher priority package always is chosen first, if multiple packages have same priority then the last added one is chosen first. Flags is only currently has 1 possible flag (value 1) it means ignore conditions on the package, if 0 then don't ignore conditions. You will have to test if the package is removed on finish, not sure about it.

Posted

This is strange:

Usually an Actor has a package stack - that means that always the first possible package will run. Now you say it will be the last in case of similar priority. Are you sure?

Posted

PackageOverrides stay forever, and every time the AI of the NPC is refreshed it may be re-executed, also if it is completed.

You have to remove them.

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...