Guest Posted March 31, 2016 Posted March 31, 2016 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. Â
zaira Posted March 31, 2016 Posted March 31, 2016 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...
Veladarius Posted April 4, 2016 Posted April 4, 2016 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.
Ashal Posted April 4, 2016 Author Posted April 4, 2016 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
Veladarius Posted April 4, 2016 Posted April 4, 2016 Thanks for the help Ashal, that has things going now.
darkconsole Posted April 4, 2016 Posted April 4, 2016 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. Â rebuild mod start new game cast on six actors save game load game OnGameReload() - empty data set. whatever skyrim does between that and giving me game control 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.
darkconsole Posted April 4, 2016 Posted April 4, 2016 Â 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...? Â
darkfender666 Posted April 6, 2016 Posted April 6, 2016 Easy question but really important.. Â Should i overwrite Sexlab files with papirus util files or not?
Ashal Posted April 6, 2016 Author Posted April 6, 2016 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.
darkfender666 Posted April 6, 2016 Posted April 6, 2016 Â 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
PegasusKoga Posted May 1, 2016 Posted May 1, 2016 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.
Guest Posted May 1, 2016 Posted May 1, 2016 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.
PegasusKoga Posted May 2, 2016 Posted May 2, 2016  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.
Bondage-Sealed Posted May 10, 2016 Posted May 10, 2016 i have no idea what any of this means but other mods say its good to have so i have it
Guest Posted June 5, 2016 Posted June 5, 2016 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.,
Guest Posted June 20, 2016 Posted June 20, 2016 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. Â
Ed86 Posted July 14, 2016 Posted July 14, 2016 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) ?
Guest Posted July 14, 2016 Posted July 14, 2016 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.
Ed86 Posted July 14, 2016 Posted July 14, 2016  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?
Guest Posted July 14, 2016 Posted July 14, 2016 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 Â
Ed86 Posted July 14, 2016 Posted July 14, 2016  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
zaira Posted July 16, 2016 Posted July 16, 2016 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?
h38fh2mf Posted July 16, 2016 Posted July 16, 2016 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.
zaira Posted July 16, 2016 Posted July 16, 2016 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?
Guest Posted July 16, 2016 Posted July 16, 2016 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now