[Solved ] Change the Attribute of a variable object

I want to change what happens within a lot of rooms every few turns with a single function.

What happens is random for every room, goverend by GetRandomInt(1, 4).

Since more rooms will be added later down the line, I made a list in which I can put the name of the new room and have the script work through it one by one.

However, I can't find a way to use the list of names in the actual script itself.

The basic principal of how it works is supposed to be like this:

foreach (NameOfRoom, [List]) {
    [NameOfRoom].Event = GetRandomInt(1, 4)

But as I said, I don't know how the [NameOfRoom] part would work.

Is there any way I can do this without hardcoding every single room?

Is the list a stringlist, or an objectlist?

If it's an objectlist, containing the rooms, this should work fine.
If it's a stringlist containing the names of rooms, you can do it like this:

foreach (NameOfRoom, [list]) {
  room = GetObject (NameOfRoom)
  room.Event = GetRandomInt(1, 4)

Log in to post a reply.