Dynamic objects

Here is the crux of the issue: I don’t know how to access elements of a list.
I thought this would work:

An adventurer is a kind of person. 
An adventurer has some text called advName.

[Template characters to be renamed and reused.]
The Team is a list of adventurers that varies.
X, Y, Z, W are adventurers.
Team is {W, X, Y, Z}.

The advname of Z is "no one".
Understand the advname property as describing an adventurer.

Data is a kind of value. The data are stName, stSex, stClass, stDex, complete, and paused.
Stage is data that varies. Stage is stName.
AdvNext is some text that varies.
OrdList is a list of text that varies. OrdList is {"first", "second", "third", "fourth"}.
AdvCounter is a number that varies. AdvCounter is 0.

Lobby is a room. 
Description of Lobby is "[if unvisited]Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams. Soon a team of adventurers will gather in the Lobby.[else] A team is gathering: [end if] ";

After looking in location:
	say "You see ";
	repeat with N running through Team:
		**say "advName of [entry N of Team]";**
	follow the adventurer-printing rule;

The compile error is
Problem. You wrote ‘say “advName of [entry N of Team]”’ : but that doesn’t make sense to me as a list entry, because the indication of which entry is not a number. For instance, ‘entry 3 of L’ is allowed, but not ‘entry “six” of L’. (List entries are numbered 1, 2, 3, …)

If I get it to compile, then a second adventurer, created by the player, overwrites the first adventurer.

In entry N of Team, N must be a number. Your repeat loop runs through a list of adventurers, so N is an adventurer.

1 Like

OK, that explains the error, but how do I say I want the Nth adventurer in the Team list, and then a particular property of that adventurer, say advName?

advName of entry N of Team

Right, you need to either make N a number (so index on the number of entries in team) or if N is staying an adventurer, just do “[advname of N]”.

1 Like

Zed,
I’ve used the phrase many times and it gives a compile error.

This phrae looks like it is working. It makes sense now since Zed explained that N is not a number but an adventurer.