Iterate all "elements" in a room

Started by fratello Manu, Thu 28/01/2021 15:38:10

Previous topic - Next topic

fratello Manu

Hi everyone! I couldn't find an answer... I need to iterate all elements of current room, to display their descriptions somewhere.
I'd like to do this for every character, object and hotspot (let's pretend, to display names in a Label)

So I need something like:

Code: ags
String result = "this room contains: ";

for (every hotspot in room.hotspots)
{
  result = result.Append(hotspot.Description);
  result = result.Append(", ");
}

for (every character in room.characters)
{
  result = result.Append(character.RealName);
  result = result.Append(", ");
}

for (every object in room.objects)
{
  result = result.Append(object.Description);
  result = result.Append(", ");
}


Does someone know if there's a way to do this?

Thanks!
Have a nice day

Crimson Wizard

#1
Code: ags

for (int i = 0; i < AGS_MAX_HOTSPOTS; i++)
{
    Hotspot* h = hotspot[i];
    // do something
}

for (int i = 0; i < Room.ObjectCount; i++)
{
    Object* o = object[i];
    // do something
}

for (int i = 0; i < Game.CharacterCount; i++)
{
    Character* c = character[i];
    if (c.Room == player.Room)
    {
        // do something
    }
}


SMF spam blocked by CleanTalk