Unspecific object with certain alias.

CheeseMyBaby
17 May 2018, 19:24Let's say I have several boxes of ammo named "ammo", "ammo1", "ammo2" etc.
They all share the same alias... guess what it is? Indeed, it's "ammo".
Is it possible to script an alias check?
Something like if (Got(object.alias = ammo))
?
I know that doesn't work. I tried it, and lots of variations of it. But.. is it possible, somehow?

CheeseMyBaby
17 May 2018, 19:56To clarify: I want to check if the player is carrying ammo.
I don't want it to matter if the name of the object is ammo or ammo1 etc.
The Pixie
17 May 2018, 20:03You would need to go through the inventory and check each item.
gotammo = false
foreach (o, ScopeInventory()) {
if (object.alias = ammo) {
gotammo = true
}
}

CheeseMyBaby
17 May 2018, 20:14Ah, I suspected it wasn't a difficult task.
Many thanks Pix!
hegemonkhan
18 May 2018, 09:59quick fix on Pixie's code (he just forgot to put the double quotes on 'ammo'):
gotammo = false
foreach (o, ScopeInventory()) {
if (object.alias = "ammo") {
gotammo = true
}
}
mrangel
18 May 2018, 12:57In many cases, it might be more efficient to do:
myammo = FilterByAttribute (ScopeInventory(), "alias", "ammo")
if (ListCount (myammo) > 0) {
// whatever...
If you later want to find the ammo object, for example so you can remove it, you can use PickOneObject(myammo)
.

CheeseMyBaby
18 May 2018, 20:46Cool! Thanks mrangel!