Dear all,
I have two rooms. When I move between them I want to change a variable of an object.
west: TravelMessage {
destination=Room02
canTravelerPass(traveler) { return lamp.flagged; }
explainTravelBarrier(traveler){
"You can't the lamp is read.";
}
travelDesc="You go west."
}
I have an object “lamp”, and when I go west I want to change lamp_flagged to false AFTER I’ve checked if the move is possible (before or after the actual move, but after the check whether the move is okay). How do I achieve that?
Thanks and kind regards,
G.
1 Like
The way I see it, you could do this in two ways.
One of which is by turning TravelDesc into a method, like so:
west: TravelMessage {
destination=Room02
canTravelerPass(traveler) { return lamp.flagged; }
explainTravelBarrier(traveler){
“You can’t the lamp is read.”;
}
travelDesc(){
lamped.flagged = false;
“You go west.”;
}
}
The other way to do this is by defining a noteTraversal method on the travel connector.
west: TravelMessage {
destination=Room02
canTravelerPass(traveler) { return lamp.flagged; }
explainTravelBarrier(traveler){
“You can’t the lamp is read.”;
}
noteTraversal(traveler)
{
lamped.flagged = false;
}
travelDesc=“You go west.”
}
2 Likes
Method 1 works fine, thanks a lot!
No problem. Glad I could help.