Jump to content

Need Help: Basic Auto Sort Script


bluemarvin

Recommended Posts

Thanks in advance for any ideas.

 

Working on a basic script to auto sort items, and am starting with a bread box -- basically when the player opens the box, it's supposed to check how many pieces of bread they have in their inventory.... then eventually I'd like to have it automatically removed and placed in the box.

 

So problem is, I can't seem to pull valid references. I made a list called BreadList and placed in it the two types of bread in the game. Then I made this script:

 


Scriptname CL_BreadSortScript extends ObjectReference
{Auto sorts bread into bread box.}

message property CL_SortBreadMsg auto

formlist property MyBreadList auto

objectreference Bread1
objectreference Bread2

int ListIndex

int Bread1Count
int Bread2Count

Event OnOpen (ObjectReference akActionRef)

    ListIndex = MyBreadList.GetSize()

    Bread1 = MyBreadList.GetAT(0) as ObjectReference
    Bread2 = MyBreadList.GetAT(1) as ObjectReference

    Bread1Count = Game.GetPlayer().GetItemCount(Bread1)
    Bread2Count = Game.GetPlayer().GetItemCount(Bread2)
    
    Debug.MessageBox("Size is " + ListIndex + ". Ref 1 is " + Bread1 + " and ref 2 is " + Bread2 + ".  You have " + Bread1Count + " pieces of bread type 1 and " + Bread2Count + " pieces of bread type 2 in your inventory.")


EndEvent

 

Even though I set MyBreadList to point to BreadList in Properties, and even though BreadList has two items in it, the debug message returns ListIndex as "0" and Bread1 and Bread2 as "None" and both counts as 0. I have three bread items in inventory. Any thoughts?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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