Switch statements; and random time

Sometimes I’m not sure if I’m missing something or the code is missing something. Admittedly, so far it’s always me; but why doesn’t this work?

[code]The Square is a room. Greta is a woman in The Square. John is a man in The Square. Asako is a woman in The Square. SeungHo is a man in The Square.

Instead of examining:
if noun is:
– a man: say “He’s handsome.”;
– a woman: say “She’s beautiful.”[/code]

It gives me the error message:

Problem. The case '-- a man' is required to be a constant value, rather than something which has different values at different times: specifically, it has to be the name of an object. Problem. The case '-- a woman' is required to be a constant value, rather than something which has different values at different times: specifically, it has to be the name of an object.

But this does work:

Instead of examining a person in The Square: if noun is a man, say "He's handsome."; if noun is a woman, say "She's beautiful."

And while I’m here: I want my game to start at a random time. I tried The time of day is a random time. but that gives an error message Problem. The sentence 'The time of day is a random time' tells me that 'time of day', which is a time that varies, should have value 'random time', but this is the name of an object and not a time.

So I tried When play begins: change the time of day to a random time. but then suddenly it starts complaining about other things in the code which had until now been working fine, all on the pattern of Problem. You wrote 'change the hair-colour of the folk to a random hair-colour' , but 'hair-colour of the folk' is supposed to be a property whose kind of value is a hair-colour, so it cannot be set equal to a random hair-colour, whose kind is a hair-colour.

Buh? And moreover, what?

Zeborah

The error message says it basically. You have to use exact object names with switch statements, not kinds like man and woman. I’m not sure why this is so but it appears to be a limitation of I7.

Hard to tell without seeing the code, but I tried this:

[code]The lab is a room.

Hair-colour is a kind of value. Hair-colours are black, brown, red and blonde. A person has a hair-colour.

When play begins:
change the time of day to a random time;
repeat with folk running through people:
change the hair-colour of the folk to a random hair-colour.[/code]
which works without problems. Are you using the latest build (5Z71)?

Nitku wrote:

Ah well, I guess I’ll go on doing it the long way then.

I thought I was using the latest build seeing as how I downloaded it only a couple of days ago, but it was 5U92; googling now I see I must have been on the wrong site. I’ve just downloaded 5Z71 and that fixes whatever the problem was.

Thanks!

Zeborah