In my game people can get security clearances to allow access to different parts of the spaceship. When the security device is examined, I want it to list the clearances that have been added to the device. So I wrote the following function to print out which clearances are present. There is an boolean attribute SecurityClearance on such clearance objects, and if it is set to true then the player has that security clearance. But here's my problem, the code shown below works fine, making a list of the name attributes of all present clearances. However, if I swap .name for .alias which is actually what I want to display, I get a error such as:
Error running script: Error compiling expression 'Printed + ObjectListItem(DisplayList,loop).alias + ", "': Unknown object or variable 'alias'Any ideas? Thanks in advance.
<function name="ListSecurityClearances">
Printed = "The following security clearances are currently uploaded to this device: "
NumClearance = 0
DisplayList = NewObjectList()
foreach (obj, game.SecurityClearanceList) {
if (obj.SecurityClearance) {
NumClearance = NumClearance + 1
list add (DisplayList, obj)
}
}
if (NumClearance = 0) {
Printed = Printed + "None."
}
else if (NumClearance = 1) {
Printed = Printed + ObjectListItem(DisplayList,0).name + "."
}
else {
for (loop, 0, NumClearance - 2, 1) {
Printed = Printed + ObjectListItem(DisplayList,loop).name + ", "
}
Printed = Left(Printed, LengthOf(Printed) - 2)
Printed = Printed + " and " + ObjectListItem(DisplayList,NumClearance - 1).name + "."
}
msg (Printed)
</function>