Please use the Preformatted Text option (in the toolbar) when posting code examples, it makes them easier to read. Based on the the version number you mentioned and the syntax of your code example I will assume you are using the Harlowe v3.1.0 story format.
There are a number of methods you can use to automatically track the current location of the Main Character. The following solution uses a known Passage Tag combined with a header tagged passage to automatically update a story variable ($room).
warning: the following code has not been tested, it make contain syntax errors.
1: Initialise the story variable within your project’s startup tagged passage.
(set: $room to "")
2: Create a header tagged passage and add the following code to it. The code checks if the current passage being viewed has been assigned a room tag, and if so it updates the $room variable with the name of the current passage. The code uses the (passage:) macro to obtain the current passage’s tags and name. You can name the passage whatever you like, I named it Track Location
{
(set: _passage to (passage:))
(if: _passage's tags contains 'room')[(set: $room to _passage's name)]
}
3: Assign the room passage tag to each of the passages that represent a ‘location’ in your project.
eg. if you have a ‘location’ passage named Library then assign it the room tag.
In your example you are using a (goto:) macro to automatically forward the reader to another passage, there are a number of potential issues with using this method to handle ‘events’:
a. It pads the History with potentially unnecessary entries.
b. The (goto:) executes before the reader has a chance to read the contents of the current ‘location’ passage. eg. they won’t get to read the contents of the Library passage.
4: The following is a corrected variation of your own random event code, in case you want to continue using the (goto:) method of handling events. I have removes the invalid usage of the is keyword when using a mathematical operator (like >=) to compare a variable to a Number.
{
(set: _roll to (random: 1, 5))
(if: _roll >= 4)[(goto: "BusEvent")]
}
5: You can use the current value of the $room variable to forward the reader back to the previous ‘location’ passage.
(link-goto: 'Continue', $room)
6: If you prefer to display the (initial) contents of the event within the ‘location’ instead then you could use a combination of a Named Hook, a (replace:) macro, and a (display:) macro to do that. Add in following to the Library passage.
You are standing outside the library...
|event>[{
(set: _roll to (random: 1, 5))
(if: _roll >= 4)[
(replace: ?event)[(display: "BusEvent")]
]
}]