ListExclude help

Hi. I have an object list called "BagExclude", which is a list of items I do not want to be moved to "caching bag" when the following is called.

foreach (x, ListExclude (ScopeInventory(), BagExclude)) {
MoveObject (x, caching bag)

I've been round and round in circles with the help guide and some things I can find on this forum but I'm not getting anywhere. What am I doing wrong?

Error running script: Error compiling expression 'ListExclude (ScopeInventory(), BagExclude)': Unknown object or variable 'BagExclude'

I'm guessing it's a syntax thing as I have checked the list is set up correctly by simply printing the list, and that works fine.

It might be worth noting, this worked fine when I was excluding a single item, rather than a list, from the sript:

foreach (x, ListExclude (ScopeInventory(), caching bag)) {
MoveObject (x, caching bag)

I now need to keep additional items out of the caching bag - hence trying to find a way to make this work with a list!

So, I have found a way to work around this using nested ListExcludes, which will work while the number of exclusions remains low. This may affect my longer term design of the adventure if I can't find a way to exclude a list rather than single items, though :(

ListExclude (ListExclude (ScopeInventory(), caching bag),GPSr)

Can't help with the solution to your prob, but it's good to see another cacher on here ;-)

It's saying that the variable BagExclude doesn't exist.

Are you sure the code that creates that list is correct?
Does the code that creates the list come earlier within the same script?

Nope, I run the script to create the list when the game loads (I think - I've put it under "game -> scripts")

BagExclude = NewObjectList()
list add (BagExclude, GPSr)
list add (BagExclude, caching bag)

Looks like you've set up a local variable instead of a global one. Try changing all occurrences of 'BagExclude' to 'game.BagExclude'.

Perfect, thanks.

Variables only exist until the end of the script that creates them, and can only be accessed within that script.

By changing it to game.BagExclude, you make it an attribute of the game object, so it continues to be accessible as long as that object exists.

I would have probably used an attribute name like caching bag.excludes, because the list seems to be related to that object. But as long as you remember which object a particular attribute belongs to, that's really a personal preference.

Log in to post a reply.