updating hyperlinks

Hi guys.

Once again, I have an interesting challenge :-)

I want to do this.

  • Player is in a lift
  • There are 3 buttons (b1, b2, b3)
  • Access to the third floor is restricted. This is indicated with a small lamp glowing red. The others glow green.
  • If the player just presses b3, he gets an errormsg saying that the floor is off limits.
  • To go to the third floor he must first swipe a card through a card reader.
  • this will make the lamp on b3 to turn green
  • Now when he presses b3, the lift moves as normal

At first sight this looks easy.
Just maintain a flag and flip it when the card is swept.
At the same time change the color of the lamp.

But for a liftbutton there is a problem.
You can't run a script when the button is pressed.
So you can't prevent the button from working.

So next possible solution.
Have a liftbutton and an inanimate object looking the same but with different colors in the lamp.
Then either move them back and forth to an offstage room or flip the visible flag.

Both of these works fine.

But there is one annoying problem for both of them.
When the room description for the lift is printed, the buttons will appear as clickable links.
But if you have moved the buttons around or flipped the visible flag, b3 is no longer a link.
(In the description scrolling up)
It is just text.

So it cannot be clicked.
In the inventory it is ok and clickable.

This is annoying.
But it could be solved by issuing a look command,
In the new instance of the description the links are ok again.
But first of all it is not very elegant.
And secondly I can't figure out how to issue the "look" command from inside a script.

Any ideas?

BR Benny


Doctor Agon posted the solution (just after this one).

(I missed the part where you referenced not being able to changed the buttons' PRESS scripts.)

Hi BR Benny,
There is a simple way to do this.
On your 'b3' button's verb tab. You'll see two verbs; one labelled 'press;push', the other one labelled 'move'.
Both are currently grey in colour, and say 'Make Editable Copy'.
Click on the one for 'press;push' and press to 'Make Editable Copy'.
Okay, you are now free to set your flag, turn your light green, and access the third floor.
Cut the '_PressButton' function out and paste it after the then box, and put a suitable out of order message in the else box.

if (GetBoolean(card, "access")) {
  _PressButton (this, false)
else {
  msg ("Access Restricted to Authorized Personnel!!!")

Hope this helps.

I think that locking one floor is a common thing you'd want to do with a lift.

So maybe LiftLib should modify the default "push" verb for the liftbutton to include…

  if (GetBoolean(this, "locked")) {
    if (HasString(this, "lockedmessage")) {
      msg (this.lockedmessage)
    else {
      msg (DynamicTemplate("LockedObject", this))
  else {
    [... code to go to the floor ...]

Then, someone using the library doesn't need to override the function; they can just add whatever verbs they need, or have a separate card reader object, to change the button's "locked" flag.

I have updated LiftLib to allow for this. Instructions here:

That is just great!

Thank you Pixie.

Did you include K.V's grid stuff?

Er... Well it should now!

I have not tested the map stuff, as I do not use it, so let me know if it works okay.

(I was already thinking that "container_locked" is a weird type to have. I think the features list should have separate tickboxes for "is a container" and "can be locked", with them coming up on separate tabs. That way, you could make a lift button type that looks at the "locked" attribute; and if someone wants a lockable lift button then can just tick lockable on the features list. Similarly, if someone makes a library that adds a "combination lock" tab, it would just work with both lockable containers and lockable buttons. Even with other things you might want to lock)

((Though you'd want to keep the "container_locked" type for legacy compatibility))

(((Bah… while writing this I ended up thinking about creating a padlock, that can be placed on any container, door, or switch that has a hasp. Making a puzzle where you're trying to smuggle some objects into a building, and different NPCs are capable of picking different types of locks, and have different behaviours to control whether they lock them again afterwards, so you have to work out which order to put the boxes inside each other, and which lock to put on each box… Like the puzzle they give in crypto lessons where you have to send somebody else a padlock in a box, and keep the key somewhere safe)))

I have now tested the new liftlib.

It works beautifully.
Both the locking and the mapping.

Thanks Pixie :-)

This topic is now closed. Topics are closed after 60 days of inactivity.