HasStringList?

Hi, not sure if this is doable.
I know I can check if an object 'HasString' attribute, but is there a way to check if an object has a 'String List' attribute.


Hello!

Here's a silly example:

game.fake_att = NewStringList()
list add (game.fake_att, "one")
list add (game.fake_att, "two")
list add (game.fake_att, "three")

Now that I've made a string list attribute, here's the code you really want:

if (TypeOf(game,"fake_att") = "stringlist") {
  msg ("YES")
}
else {
  msg ("NO")
}

...or you could create a function:

FUNCTION NAME: HasStringList
PARAMETERS: obj & att
RETURN TYPE: Boolean

SCRIPT:

if (TypeOf(obj,att) = "stringlist") {
  bool = true
}
else {
  bool = false
}
return (bool)

After creating that function, we could change my earlier code to this:

if (HasStringList(game,"fake_att")) {
  msg ("YES")
}
else {
  msg ("NO")
}

(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


RH already mentioned the main Function for checking Attribute Types:

'TypeOf' ( http://docs.textadventures.co.uk/quest/functions/typeof.html )

some examples may not work (not sure on some of the names/syntax of them)

if (TypeOf (OBJECT, "ATTRIBUTE") = "int") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "integer") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "double") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "boolean") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "string") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "object") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "script") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "stringlist") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "objectlist") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "stringdictionary") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "objectdictionary") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "scriptdictionary") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "list") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "dictionary") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = "null") {
  // blah scripting
} else if (TypeOf (OBJECT, "ATTRIBUTE") = null) {
  // blah scripting
}

you may be able to use the generalized (hard-coded/internal) Attribute Functions too:

'HasAttribute' ( http://docs.textadventures.co.uk/quest/functions/hasattribute.html )

'GetAttribute' ( http://docs.textadventures.co.uk/quest/functions/getattribute.html )


That's great guys. Thanks. Really helpful as always.


Log in to post a reply.

Support

Forums