StackLib

Hello, I newly added StackLib and I am making a keychain in the game. But the keys that I take aren't going to the keychain. I think I did eveything true but it is still not working.


Can you show us the game, or the part of it that isn't working?


How do I add a picture?


If you want to share a picture, you can upload it to a site like imgur and give us a link. However, it would be a lot more useful to see the relevant code.


This is the code of the key:

<object name="Key of the Bedroom">
        <inherit name="editor_object" />
        <inherit name="childstack_object" />
        <look>It is the old key of your bedroom.</look>
        <take />
        <stackparent type="object">Keychain</stackparent>
        <ontake type="script">
        </ontake>
        <usedefaultprefix type="boolean">false</usedefaultprefix>
      </object>

And this is the code of the keychain:

<object name="Keychain">
      <inherit name="editor_object" />
      <inherit name="stack_container" />
      <alias>Keychain</alias>
      <inventoryverbs type="stringlist">
        <value>Look at</value>
      </inventoryverbs>
    </object>

It's been 2 days and unfortunately I still have not received a reply. I will be pleased if you help me.


I think this is your problem:

       <take />

Looks like you're setting the key's "take" behaviour to "Default can be taken", replacing the script that's added by childstack_object.

Try removing that property from the key.


I did it but there is still a take button but it is not working. The key isn't disappearing or going to keychain. It's just giving me you take it message.


I did it but there is still a take button but it is not working. The key isn't disappearing or going to keychain. It's just giving me you take it message.

Is there no longer a take attribute on the key?

"You take it" should only appear if you have that <take /> attribute (which corresponds to the "can be taken" checkbox in the editor).


There is, but it is "false"


There is, but it is "false"

That's your problem then.

If it has a take attribute that is true, it follows the default behaviour for an object that can be taken.

If it has a take attribute that is false, it follows the default behaviour for an object that can't be taken.

If it has a take attribute that is a script, it will run that script when the player tries to take it.

If it doesn't have a take attribute, then it will inherit this attribute from its types.

The take attribute of the childstack_object type adds it to the appropriate stack.

In order to use this attribute, the object needs to not have a take attribute of its own.

I believe that (because of an oddity in the way the editor handles types), if you click the "Can be taken" box in the editor (either to select it or deselect it) then you will need to use code view to remove the take attribute again; as the editor doesn't give a way to entirely remove an attribute.

Alternatively, you could give it a "Run a script" take attribute that is a copy of the one from the childstack_object type:

      if (this.alias = null) {
        this.alias = this.name
      }
      container = this.stackparent

      this.parent = container
      SetStack(container)
      if (this.takemsg = null) {
        msg(DynamicTemplate("TakeSuccessful", object))
      }      
      else {
        msg (this.takemsg)
      }

I am taking this error but it is working:
Error running script: Error compiling expression 'container.parent = Stack Containers': Unknown object or variable 'Stack Containers'
I am taking this error both when I take it and look at it in the keychain. Also, before this stack thing, I was using "if player is carrying object" script to pass through a door. But it isn't working now because the key is in the keychain. How can I make an alternative door system?


There needs to be an inaccessible room named Stack Containers, where stack containers (such as the keyring) are stored until the player has items that can go in them.


Thanks, it worked. What about the alternative door system?


My first guess would be changing your if statement to use an expression like Contains (Keychain, Key of the Bedroom) to check if the key is on the chain.


Thanks, it worked. Also I will be very happy if you look at that topic of mine:
http://textadventures.co.uk/forum/quest/topic/2-uxyot1n0cw2p-70em3yq/monsters-in-combatlib


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

Support

Forums