basic question about restricting objects added to containers

This is probably a very dumb question! But thank you in advance!

I have a question about containers: specifically about adding objects to a container. I have no idea what coding to use to restrict the “add” to just one or a few objects. I feel like I should be using “switch” or running an attribute or soemthing similiar, I just don’t know how to impliment it.

For instance: I have a lantern that contains a little fire spirit. It can be taken out of the lantern. I also want the player to be able to put it back in. But I don’t want them to be able to put other things into the lantern, such as a book or something. It’s not necessary to put the fire spirit back into the lantern, and obviously not a big deal if the player takes the time to shove large things into smaller things because they want to? But I’d like to learn! So just in general, how do I create a way to restrict items?

I don’t have much knowledge of Quest beyond basic stuff, and I can usually find a work around. Any help is welcome, especially if you can dumb it down a little for me as I am not very good with code! I am using the browser version if that changes anything.


On the container tab, there is an option for "Script to run when trying to add an object".

You'd want to set that to something like:

if (object = firespirit) {
  MoveObject (object, destination)
}
else {
  msg (CapFirst (object.article) + " won't fit in the lantern.")
}

(replacing firespirit with the name of your object)

When trying to put an object into a container, the addscript has access to the variables object and destination that you can use to examine either.


Thank you so much! I really appreciate it!! :)