Another clothing question.

I'm trying apply sizing to my clothes, and the web help section on clothing gives me the code to apply that, but it doesn't tell me where to input said code, and for the life of me, I can't figure it out. I tried putting it in the After wearing the object section, but as the name suggests, it puts the item on first, and then I just get a bunch of errors.

The code looks as follows:

if (GetBoolean(object, "toosmall")) {
  msg("That is too small for you!")
  return (false)
return (true)

Also I'm not clear on the object part of the code. I keep putting shirt.toosmall there, and I think thats where some of the errors are coming from, but what else do I put there? It would also help if I knew what return actually meant.

There is no variable object unless you've created one.

In the "after wearing" script (and just about every other script attached to an object), you can refer to the object itself as this.

Also, you can't use return in a script attribute; it doesn't do anything useful.

I tried putting it in the After wearing the object section

It looks like that code belongs in a function named TestGarment.
TestGarment is a function which is run when the player tries to wear a garment, and if it returns false the garment isn't worn.

Unfortunately, you can only edit this in the desktop editor; it's not an option online. There is a default function called TestGarment which always returns true, and the web editor doesn't allow you to modify core functions.

If you want to do it using the web editor, your "after wearing" function would become something like:

if (GetBoolean (this, "toosmall")) {
  msg ("That is too small for you.")
  _DoRemove (this)

OR you could modify the wear command so that it checks before doing everything else. The online editor doesn't let you modify core commands, either, but you can change them during the game. So you would put this in your game's start script:

wear.script => {
  if (multiple and ListCount(object) = 0) {
    foreach (obj, object) {
      if (multiple) {
        OutputTextNoBr(GetDisplayAlias(obj) + ": ")
      if (GetBoolean (obj, "toosmall") and ContainsReachable (game.pov, object)) {
        msg ("That is too small for you.")
      else {
        f = _DoWear(obj)

(That's mostly the default wear script with a few lines added. I checked ContainsReachable so that it only gives the "too small" message for garments the player is carrying; but you might want to change that)

I am using the desktop version, sorry, I should have specified. So knowing that, how do I alter the TestGarment and other core functions?

Log in to post a reply.