Can't buy "wearable objects"

I set up a shop using the following tutorial. (http://docs.textadventures.co.uk/quest/shop.html). I can buy and sell objects; however, if the object is a wearable object (i.e. helmet). I get the following message: "Error running script: Unrecognised list type". Any idea where to look to fix this?


I can't see how that problem could happen; but I can think of a few questions that might help to narrow it down.

Does the error appear when you enter the shop, or when you try to buy a wearable item?

Once you add the helmet to the stock, do other items in the shop still buy/sell normally?

After the error message has appeared, does the item still appear? Can you then buy other items normally?


The error does not appear when you enter the shop.
I am able to buy a non wearable item from the shop.
Once I buy a wearable item, the item appears in my inventory, but the message appears.
I am able to buy non wearable items after the error message.


Ah, got it.
In the "buy" function, there is a line:

 list remove (obj.generatedverbslist, "Buy")

But it looks like the wearable type prevents the generatedverbslist from being generated. So you'll need to change that to:

if (HasAttribute (obj, "generatedverbslist")) {
  list remove (obj.generatedverbslist, "Buy")
}

I think I've found that issue before, but I'd forgotten it.

Actually, there are cases where the other two might not exist either. So it's probably best to replace:

  list remove (obj.generatedverbslist, "Buy")
  list remove (obj.displayverbs, "Buy")
  list remove (obj.inventoryverbs, "Buy")

with:

foreach (attr, Split("generatedverbslist;displayverbs;inventoryverbs")) {
  list = GetAttribute (obj, attr)
  if (EndsWith (TypeOf (list), "list")) {
    if (ListContains (list, "Buy")) {
      list remove (list, "Buy")
      set (obj, attr, list)
    }
  }
}

A bit over-complicated, but should prevent it causing problems if any other library has played with the verbs lists.


Thank you, that solved it.


Log in to post a reply.

Support

Forums