Using ForEach to add display verbs to multiple objects at once

I'm trying to do a little automation with lists, the idea I have is when one event triggers it will put new display verbs on all characters of a certain faction. have the list working fine in filtering the faction npcs(Using the display list function to check) but when I do a for each to actually add the verbs i get a
Error running script: Unrecognized list type
I think I am missing something quite simple... but have yet to figure it out.

allobjects = AllObjects()
FactionAggressive = FilterByAttribute(allobjects,"agressive",true)
DisplayList (FactionAggressive, false)
foreach (i, FactionAggressive) {
  list add (i.displayverb, "Intimidate")

The attribute is displayverbs.

Does your game logic ensure that none of the characters already have that displayverb, and that their displayverbs aren't inherited? Maybe you do, but if you're not sure it would be wise to guard against future bugs by doing something like:

foreach (i, FactionAggressive) {
  if (not ListContains (i.displayverbs, "intimidate")) {
    i.displayverbs = i.displayverbs
    list add (i.displayverbs, "Intimidate")

Yeah, was something simple, the displayverbS was the thing i was missing. mind was thinking "Oh its only one item, so its a verb" mind was not thinking with machine logic

A similar follow-up though, more of it "can it work?" question. trying to search for any item with a certain string in its alias, if found one reaction, found an old post of yours that had this that SEEMS almost what I need, but would want it to search any string that has "Venture" in its name, so Venture baggage, Venture insignia, ect, I'm thinking I'd have to use some sort of function or regrex but don't think it would fit in the same If statement.

if (ListCount (FilterByAttribute (ScopeInventory(), "alias", "club")) > 0) {

Don't know if it matters but using the Clone prototype and Move to generate the items I'm looking for, which have semi random names. Since I use multiple prototypes like this how would "Prototype" know which one it was looking for? Essentially each item has a MFG(Venture in this case) and an actual item for the alias.

A few options; roughly in order of efficiency:

If all clubs are clones of the same original/prototype, it would be much more efficient to do:

if (ListCount (FilterByAttribute (ScopeInventory(), "prototype", original_club_object)) > 0) {

If there are multiple objects that it could be cloned from, you could give them all a type and do something like:

if (ListCount (FilterByType (ScopeInventory(), "club")) > 0) {

or give those objects an attribute you can easily check for:

if (ListCount (FilterByAttribute (ScopeInventory(), "weapontype", "club")) > 0) {


if (ListCount (FilterByAttribute (ScopeInventory(), "isclub", true)) > 0) {

If you really need to do it using the alias, you would have to make your own filter function to take a regular expression. Something like:

<function name="FilterByAttributeRegex" parameters="list, attribute, expression" type="objectlist">
  output = NewObjectList()
  foreach (obj, list) {
    if (HasString (obj, attribute)) {
      if (IsRegexMatch (expression, GetString (obj, attribute))) {
        list add (output, obj)
  return (output)

Then you could do:

if (ListCount (FilterByAttributeRegex (ScopeInventory(), "alias", "club")) > 0) {

Alternatively, if you don't need to know which object it is, you could make a simpler function:

<function name="ListHasMatchingObject" parameters="list, attribute, expression" type="boolean">
  foreach (obj, list) {
    if (HasString (obj, attribute)) {
      if (IsRegexMatch (expression, GetString (obj, attribute))) {
        return (true)
  return (false)

so you could just do:

if (ListHasMatchingObject (ScopeInventory(), "alias", "club")) {

(this is faster because it can stop as soon as it finds one, instead of creating a whole list)

Hope that helps!

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