Papyrus: Add item from FormList

Post » Fri Nov 16, 2012 2:39 pm

I'm trying to give the player a random item from a formlist, but no item is being added. Why isn't this working?

FormList Property ItemList AutoInt iIndex = Utility.RandomInt(0, (ItemList.GetSize() - 1))ObjectReference Reference = ItemList.GetAt(iIndex) as ObjectReference(Game.GetPlayer()).AddItem(Reference, GemCount)
User avatar
Campbell
 
Posts: 3262
Joined: Tue Jun 05, 2007 8:54 am

Post » Sat Nov 17, 2012 2:31 am

You need a Form rather than an ObjectReference if caching it, or you can just...
Int iGemCountFormList Property ItemList Auto...    Game.GetPlayer().AddItem(ItemList.GetAt(Utility.RandomInt(0, (ItemList.GetSize() - 1))), iGemCount)...
User avatar
Jessie Butterfield
 
Posts: 3453
Joined: Wed Jun 21, 2006 5:59 pm

Post » Fri Nov 16, 2012 7:00 pm

You need a Form rather than an ObjectReference if caching it, or you can just...
Game.GetPlayer().AddItem(ItemList.GetAt(Utility.RandomInt(0, (ItemList.GetSize() - 1))), GemCount)
Oh. So, just to clarify: AddItem() accepts only forms?

EDIT: I'm getting these errors in trace.

[07/01/2012 - 09:04:26PM] error: Cannot call GetSize() on a None object, aborting function call[07/01/2012 - 09:04:26PM] error: Cannot call GetAt() on a None object, aborting function call
Any idea why?
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm

Post » Fri Nov 16, 2012 5:29 pm

You can pass a persistent ObjectReference or ReferenceAlias as AddItem's akItemToAdd. If ItemList is filled with base objects rather than references to them, you'd want to be accessing the FLST members as Forms rather than ObjectReferences.

Edit: You still need to have the FormList property and GemCount int.
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Fri Nov 16, 2012 1:22 pm

Yeah, those are defined. Still not getting anything.

[07/01/2012 - 10:02:43PM] error: Cannot call GetSize() on a None object, aborting function callstack:[ (0010EDBF)].MineOreScript.giveOre() - "MineOreScript.psc" Line 207[ (0010EDBF)].MineOreScript.OnActivate() - "MineOreScript.psc" Line 97[07/01/2012 - 10:02:43PM] warning: Assigning None to a non-object variable named "::temp26"stack:[ (0010EDBF)].MineOreScript.giveOre() - "MineOreScript.psc" Line 207[ (0010EDBF)].MineOreScript.OnActivate() - "MineOreScript.psc" Line 97[07/01/2012 - 10:02:43PM] error: Cannot call GetAt() on a None object, aborting function callstack:[ (0010EDBF)].MineOreScript.giveOre() - "MineOreScript.psc" Line 208[ (0010EDBF)].MineOreScript.OnActivate() - "MineOreScript.psc" Line 97[07/01/2012 - 10:02:43PM] error: Cannot add None to a containerstack:[ (00000014)].Actor.AddItem() - "" Line ?[ (0010EDBF)].MineOreScript.giveOre() - "MineOreScript.psc" Line 210[ (0010EDBF)].MineOreScript.OnActivate() - "MineOreScript.psc" Line 97

Don't bother with the line numbers. I've rewritten most of the mining script.
User avatar
Peter P Canning
 
Posts: 3531
Joined: Tue May 22, 2007 2:44 am

Post » Fri Nov 16, 2012 6:53 pm

Post the script? It compiles/works fine on this end. Is your FLST property filled?
User avatar
Jennifer Munroe
 
Posts: 3411
Joined: Sun Aug 26, 2007 12:57 am

Post » Sat Nov 17, 2012 3:32 am

Post the script? It compiles/works fine on this end. Is your FLST property filled?
Here's the script: http://pastebin.com/raw.php?i=rDUgAzQf

And here's the FormList: http://i50.tinypic.com/jqszm1.png
User avatar
Amysaurusrex
 
Posts: 3432
Joined: Wed Aug 09, 2006 2:45 pm

Post » Fri Nov 16, 2012 2:42 pm

Looking at it now.

All cases of 'Self.Function()' can be reduced to 'Function()' and you can do entirely w/o objSelf.

Only reason I can see it not finding AdraeusGemsRough is if its property is not filled.
User avatar
Ludivine Poussineau
 
Posts: 3353
Joined: Fri Mar 30, 2007 2:49 pm

Post » Sat Nov 17, 2012 2:29 am

All cases of 'Self.Function()' can be reduced to 'Function()' and you can do entirely w/o objSelf.
Yeah, there's still a lot of code remaining from the original script.
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Fri Nov 16, 2012 7:32 pm

Only reason I can see it not finding AdraeusGemsRough is if its property is not filled.
I changed the FormList to SoulGemsAll and I'm still getting the same results...
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Sat Nov 17, 2012 12:21 am

Then your property is not filled in the CK. The code works...
[07/01/2012 - 10:02:43PM] error: Cannot call GetAt() on a None object, aborting function call
Your FormList property has no value.
User avatar
Jordyn Youngman
 
Posts: 3396
Joined: Thu Mar 01, 2007 7:54 am

Post » Sat Nov 17, 2012 1:13 am

Then your property is not filled in the CK. The code works...
[07/01/2012 - 10:02:43PM] error: Cannot call GetAt() on a None object, aborting function call
Your FormList property has no value.
I don't understand. SoulGemsAll is a vanilla FormList. And my FormList looks pretty filled to me: http://i50.tinypic.com/jqszm1.png
User avatar
CHangohh BOyy
 
Posts: 3462
Joined: Mon Aug 20, 2007 12:12 pm

Post » Fri Nov 16, 2012 5:58 pm

I don't understand. SoulGemsAll is a vanilla FormList. And my FormList looks pretty filled to me: http://i50.tinypic.com/jqszm1.png
Not the FormList itself, but the script's http://www.creationkit.com/Variables_and_Properties#Declaring_Properties which is to be pointed to the FormList.

Say you make a PlayerREF property in a script...
Actor Property PlayerREF Auto
...and attach that script to a MISC items. In the MISC item's Scripts > Properties, the property value must be filled either manually or via auto-filling or PlayerREF == None. PlayerREF property, attached to a different script, could be pointed to MaiqTheLiarREF. Simply matching the desired target's EditorID will make it autofill with the desired form, but it'll not have a value until filled.
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Sat Nov 17, 2012 12:13 am

Not the FormList itself, but the script's http://www.creationkit.com/Variables_and_Properties#Declaring_Properties which is to be pointed to the FormList.
Do you mean "FormList Property SoulGemsAll Auto"? Because that's in there. If not, even looking at that page, I have no idea how to create a custom property or what I would do with it.
User avatar
CORY
 
Posts: 3335
Joined: Sat Oct 13, 2007 9:54 pm

Post » Fri Nov 16, 2012 6:19 pm

Edit a form the script is attached to, find its script window, and click on the "Edit Properties" button.

http://www.cipscis.com/skyrim/tutorials/editorids.aspx
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am

Post » Fri Nov 16, 2012 6:09 pm

Edit a form the script is attached to, find its script window, and click on the "Edit Properties" button.

http://www.cipscis.com/skyrim/tutorials/editorids.aspx
There are a lot of ore veins. That's a lot of edits to make... I guess the smart thing then would be to define all of my FormLists from the start.

Thank you, Justin!
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm


Return to V - Skyrim