ListExclude???

I'm trying to sort out a bit of coding with the 'ListExclude' function, and I get an error message that basically the function is not recognised, does not exist.
Is this correct?
I've looked in the game tree and its not there, but I also noticed that the function 'GetPlacesObjectsList' uses the ListExclude function, but I get no error when playing my game, so maybe the 'GetPlacesObjectsList' is not doing a lot either.

Does anyone know what the code was for 'ListExclude'.


ListExclude should work:

http://docs.textadventures.co.uk/quest/functions/listexclude.html

The above link also mentions that "ListExclude by contrast returns a copy of the list - the original list is unaffected." Don't know if that is an issue for you.

I refer to these pages a lot that explain most Quest functions:

Listed by type of function:
http://docs.textadventures.co.uk/quest/functions/

Listed alphabetically:
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html


I've looked at those pages too. I have them linked to my favourites, so I can refer to them all the time.
The function is missing. I've even opened up a new game, just in case I'd accidently deleted the function.


The function is missing.

What do you mean by "missing"?
If you mean you can't open it from the core libraries to see its code, that's because it's a hard-coded function that you can't modify.

If it's giving a function not found error when you try to use it, remember that hard-coded functions give a "function not found" error if you pass them the wrong type or number of parameters, and I think this one is a little flaky with some combinations.


I made a new, barebones game and put an apple object and a lemon object in the starting room. The player is also in the starting room. Then I put this in the Start tab:

game.testlist = ScopeVisible()
game.testlist2 = ListExclude(game.testlist, apple)
msg (game.testlist2)

When I run the game, it prints:

List: Object: lemon; Object: player;
You are in a room.
You can see a lemon and an apple.

So it works in a barebones game.

ListExclude is a hard-coded function (not in the libraries), so will not appear under Filter --> ShowLibraryElements.


Thanks guys, you've helped a lot.
Was trying to pass to it two completely different lists so it was confused.


If you're using it with 2 lists, you might need to use temporary variables.


I was trying to redesign the 'Inventory' script to split up what you are carrying and what you are wearing into two separate list.
I was trying to exclude 'ListClothes' from the 'Inventory' not realising that 'ListClothes' is a stringlist.

Instead of;
'You are carrying a car, a boat, a shirt, shoes(worn).'

You'd get;
'You are carrying a car, a boat, a shirt.'
'You are wearing shoes.'

I think I'm nearly done with it, just got to put the finishing touches to it, but I was also looking at 'FormatList' when I was doing this (I don't think 'FormatObjectList' would've worked because that required a 'parent' object), why doesn't 'FormatList' use 'GetDisplayNameLink'.

If I 'copy' then change 'FormatList', am I going to alter how another function works further down the line.


I was trying to redesign the 'Inventory' script to split up what you are carrying and what you are wearing into two separate list.
I was trying to exclude 'ListClothes' from the 'Inventory' not realising that 'ListClothes' is a stringlist.

In that case, your easiest solution is probably using something like FilterByAttribute (ScopeInventory(), "worn", true) - I assume you got that.

why doesn't FormatList use GetDisplayNameLink.

It uses GetDisplayName, which does the same thing with one less parameter. The existence of two different functions seems to be for historical reasons. But as you can see, it doesn't matter too much which of them you use:

  <function name="GetDisplayName" type="string" parameters="obj">
    return (GetDisplayNameLink(obj, ""))
  </function>

If I 'copy' then change 'FormatList', am I going to alter how another function works further down the line.

Depends what changes you have in mind. What were you planning to change?


I was going to change 'GetDisplayName' for 'GetDisplayNameLink'. That would be the only change.


I was going to change 'GetDisplayName' for 'GetDisplayNameLink'. That would be the only change.


Assuming you're passing "" as the second parameter to GetDisplayNameLink, that will make no difference at all.


Changing the 'FormatList' function as follows:

if (ListCount (list) = 0) {
  return (nothing)
}
else {
  result = ""
  count = 0
  listLength = ListCount(list)
  foreach (item, list) {
    if (TypeOf(item) = "object") {
      result = result + GetDisplayNameLink(item, "object")
    }
    else {
      result = result + item
    }
    count = count + 1
    if (count = listLength - 1) {
      if (not IsRegexMatch("^\\W", lastjoiner)) {
        result = result + " "
      }
      result = result + lastjoiner + " "
    }
    else if (count < listLength) {
      result = result + joiner + " "
    }
  }
  return (Trim (result))
}

relevant section result = result + GetDisplayNameLink(item, "object")


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums