Jump to content

PapyrusUtil - FormListAdd(none vs self)?


Recommended Posts

What is the difference between these?

StorageUtil.FormListAdd(none, [parameter], [parameter])

StorageUtil.FormListAdd(self, [parameter], [parameter])

 

I'm tweaking a mod's script and I'm having trouble grabbing the data from the forms stored with PapyrusUtil, so I'm wondering if it's because of that parameter since I don't understand what it's doing.

 

Also, how many parameters can this have? Is there a specific order to the types of parameters you can set? I'm having trouble understanding it and Google has been failing me on this topic.

Edited by NymphoElf
Link to comment

From the storageutil.psc file:

;/ Add an int/float/string/Form to a list on form or globally and return
   the value's new index. Index can be -1 if we were unable to add
   the value.

   ObjKey: form to add to. Set none to add global value.
   KeyName: name of value.
   value: value to add.
   [optional] allowDuplicate: allow adding value to list if this value already exists in the list.
/;
int function FormListAdd(Form ObjKey, string KeyName, Form value, bool allowDuplicate = true) global native

 

Link to comment

You can associate a value with a specific Form, or store it globally not associated to anything. Associating a value with a Form is useful when you want to add something specific to a character, say for instance a new character value such as hunger. If however you want to do something else like count how many times the moons have been up, you'd store that as a global as its not specific to any Form.

 

A value stored as a global can't be read from a Form, or the other way around.

 

Edit: As for what Form means; Form is a class from which other classes inherit typically. For instance the Actor class inherits the Form class. So when it says you can use any form as that parameter, it means you can use any class that inherits from Form as a parameter.

Edited by traison
Link to comment

Scriptname sr_inflateConfig extends SKI_ConfigBase

scriptname SKI_ConfigBase extends SKI_QuestBase

scriptname SKI_QuestBase extends Quest hidden

ScriptName Quest extends Form

 

Meaning, self in this case is the quest that sr_inflateConfig is currently running on. I do not have SLIF but you can find this QUST entry easily in xEdit, filter for "scriptname" and look through all quests until you find it.

Edited by traison
Link to comment

@traison

 

Ok. So then, let's say the quest in question is "sr_inflateQuest".

 

And now let's say I store a value on this form (starting on on Index 0 - assumedly):

 

StorageUtil.FormListAdd(self, "TestValue", 5)

 

If I wanted to pull an entry from that form on another script, I then need to do:

 

StorageUtil.FormListGet(sr_inflateQuest, "TestValue", 0)

 

Is this correct? Would this return my stored value of 5?

Edited by NymphoElf
Link to comment

No, because 5 is not a Form, it's an int. You'd need IntListAdd, if that exists. Also your FormListGet call would have to have a reference to sr_inflateQuest, as it can't be accessed by name, ie.:

 

sr_inflateQuest Property MyQuestReference Auto

 

This property is then set in xEdit, or the CK to the sr_inflateQuest quest. And it is used like:

 

StorageUtil.FormListGet(MyQuestReference, ...)

Link to comment

 

19 minutes ago, traison said:

No, because 5 is not a Form, it's an int.

 

Oh. I thought "self" was the form? That has me somewhat confused, but I can deal with that for now.

 

19 minutes ago, traison said:

FormListGet call would have to have a reference to sr_inflateQuest, as it can't be accessed by name, ie.:

 

sr_inflateQuest Property MyQuestReference Auto

 

This property is then set in xEdit, or the CK to the sr_inflateQuest quest. And it is used like:

 

StorageUtil.FormListGet(MyQuestReference, ...)

 

Right. Ok, this is finally starting to make sense, kind of. 

 

Let me try again.

 

----------------------------

 

--Storing Data, assumedly on "sr_inflateQuest"--

 

StorageUtil.FormListAdd(self, "ActorRace", actorReference.GetRace())  --Let's assume the race is "Nord" for this example--

 

--Calling Data on other script--

 

sr_inflateQuest Property FillHerUp Auto

StorageUtil.FormListGet(FillHerUp, "ActorRace", 0)

 

----------------------------

 

Would this return the Nord race?

Edited by NymphoElf
Link to comment

Think of it this way:

 

FormListAdd is "Add to list of forms".

IntListAdd is "Add to list of ints".

 

You'll find that a form argument is first in many of the storageutil functions. Its the 3rd argument that you're actually inserting into the list in these cases.

 

Your new attempt looks better. I realize that is probably just a snippet but if you plan to only have one value there, look into these instead:

Form function SetFormValue(Form ObjKey, string KeyName, Form value) global native
Form function GetFormValue(Form ObjKey, string KeyName, Form missing = none) global native

Link to comment
14 minutes ago, traison said:

Think of it this way:

 

FormListAdd is "Add to list of forms".

IntListAdd is "Add to list of ints".

 

You'll find that a form argument is first in many of the storageutil functions. Its the 3rd argument that you're actually inserting into the list in these cases.

 

Ok, that makes more sense.

 

14 minutes ago, traison said:

Your new attempt looks better. I realize that is probably just a snippet but if you plan to only have one value there, look into these instead:

Form function SetFormValue(Form ObjKey, string KeyName, Form value) global native
Form function GetFormValue(Form ObjKey, string KeyName, Form missing = none) global native

 

Yeah, those are just examples I wrote up for the sake of understanding the material I was asking about. The scripts I'm editing aren't entirely mine. They're from mods I downloaded and I'm just trying to get them to interact in the way I want them to and got hung up on trying to get information back out from "StorageUtil.FormListAdd" that the original author is using (I'm trying to keep as much of the original code in tact as possible). I think I'll be able to get it working now. This was the last part, so hopefully it works and I'm all done.

 

EDIT: OH, I forgot to put "as Race" at the end of my FormListGet line in the above example too

Edited by NymphoElf
Link to comment

@traison

I'm desperate... Please, please help. I've tried extremely hard to figure out what I'm doing wrong but nothing I can think of works. I've read and re-read this post more times than I was able to count. I've spent over 20 hours on this now and I'm exhausted and ready to give up.

 

I'm trying to make a sperm count multiplier for FM+ that pulls from the values in FillHerUp.

 

I've attached the scripts in question. "_jsw_sub_eventhandler" is the FM+ script I'm modifying. The other two are from FillHerUp.

 

---------------------------------------------------------------------------------------------------------------------------

 

I'm trying to multiply the sperm value in the FM+ script by the amount stored by FillHerUp, based on the inseminating race ("father" in FM+).

The variable "newSpermMultiplier" I added in "_jsw_sub_eventhandler" is supposed to be whatever value is stored in FillHerUp * 10 / 2.5 (don't worry about why I'm multiplying and dividing this value, it's just how I got the final sperm amounts I wanted for FM+ by testing the values in an Excel Spreadsheet)

 

As of right now "newSpermMultiplier" keeps getting set to 0, meaning it doesn't find the StorageUtil value I'm trying to pull.

 

Everything else seems to be working. Please, I'm going insane trying to figure this out.

sr_inflateConfig.psc sr_inflateQuest.psc _jsw_sub_eventhandler.psc

 

EDIT: I've beaten my head against the wall long enough. I can't do it. Unless someone can help me with this, I'm done trying. I just can't figure it out. Clearly I'm not understanding something and unless someone spells it out for me I don't think I ever will. I WANT to learn, but I just don't have the capacity to figure this out on my own anymore. I've tried everything I can think of.

Edited by NymphoElf
Link to comment

That's your issue. The FHU_Config property is not set to anything.

 

Edit: Guess I should clarify again. If you have set that property to something, then your issue is that the values of properties are stored in the save. In this case you got 2 options, delete the script from your save with resaver, or start a new game. I personally go the resaver route while doing development.

Edited by traison
Link to comment
5 hours ago, traison said:

That's your issue. The FHU_Config property is not set to anything.

That doesn't make any sense and infuriates me like you wouldn't believe. I tried the same test with the FillHerUp Property and it's blank for some reason too.

 

I'm finding a different solution to this issue because clearly what I've been trying to do isn't working, and at this rate never will.

 

Thank you for teaching me what you have.

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