i want the torch to spit out any non-batteries.

my request is in the title

my code is below

if (not Contains (torch,AABattery1)) {
msg ("You cannot close the cover with a non-battery in there.")
MoveObjectHere (this.child)
HelperOpenObject (torch)
}

I would like confirmation if this would actually work, and how to fix it if not.
i've made the battery already in there and untakeable, but if someone found a way to bypass that I would like to reinforce the fact that torches need batteries.


What's the point in being able to open the torch if you can't take the batteries out?

In any case, that doesn't test if there's a non-battery in there, it tests if the battery is not there. Where are you putting this script?

If you want to prevent objects being put into the torch, there's a few ways I could suggest.

  1. Make it a limited container. You said the battery can't be taken, so if you make it only large enough to contain 1 item, the player gets an "It is full" message.

  2. Use an addscript (script when the player tries to add an object) on the container. Then you can let the player remove the battery, but they can't put anything else in. Something like:

if (object = AABattery1) {
  object.parent = this
  msg ("You put the battery back in.")
}
else {
  msg ("You can't close the battery cover with a non-battery in there.")
}

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

Support

Forums