Hiding and revealing verbs
michaelsahn
02 Feb 2014, 22:59Hello –
I’m using a key to open a container. I’m using only hyperlinks that display verbs. I’m not using command line text entry.
I’d like the player to pick up the key to unlock the container. Therefore I’ve assigned the verb “unlock” to the container and associated the key with it. When the player clicks on the word “container”, the verb “unlock” is displayed.
I’d like to hide verb “unlock” associated with the container and reveal it only until after the player has picked up the key.
Also, once the player has unlocked the container with the key, I’d like to hide the “unlock” verb associated with the container.
Therefore:
1. Player clicks on word “box” and sees no verb associated with it.
2. Player picks up key.
3. Player clicks on the word “box” and now see the verb “unlock” associated with it.
4. Player unlocks the box.
5. Player clicks on the word “box” and no longer sees the verb “unlock” associated with it.
Can this be easily done?
Thanks –
Mike
I’m using a key to open a container. I’m using only hyperlinks that display verbs. I’m not using command line text entry.
I’d like the player to pick up the key to unlock the container. Therefore I’ve assigned the verb “unlock” to the container and associated the key with it. When the player clicks on the word “container”, the verb “unlock” is displayed.
I’d like to hide verb “unlock” associated with the container and reveal it only until after the player has picked up the key.
Also, once the player has unlocked the container with the key, I’d like to hide the “unlock” verb associated with the container.
Therefore:
1. Player clicks on word “box” and sees no verb associated with it.
2. Player picks up key.
3. Player clicks on the word “box” and now see the verb “unlock” associated with it.
4. Player unlocks the box.
5. Player clicks on the word “box” and no longer sees the verb “unlock” associated with it.
Can this be easily done?
Thanks –
Mike
george
02 Feb 2014, 23:28michaelsahn
03 Feb 2014, 05:00I've studied the thread and read the descriptions of the stringlist and displayverbs attributes and tried to edit the code directly, but with no success, as I'm not a trained coder.
Is there a way that I could make this change using the GUI?
Also, I've pasted my game code here - if anyone is willing to edit the code to make the game function as specified in my earlier post, I can study it.
Thanks again -
Mike
Is there a way that I could make this change using the GUI?
Also, I've pasted my game code here - if anyone is willing to edit the code to make the game function as specified in my earlier post, I can study it.
Thanks again -
Mike
<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Text test">
<gameid>399d190a-468a-4666-99e3-82eaa5d6d324</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<autodescription type="boolean">false</autodescription>
<showdescriptiononenter />
<echohyperlinks type="boolean">false</echohyperlinks>
<echocommand type="boolean">false</echocommand>
<enablehyperlinks />
<underlinehyperlinks type="boolean">false</underlinehyperlinks>
<showpanes type="boolean">false</showpanes>
<showcommandbar type="boolean">false</showcommandbar>
<defaultlinkforeground>Black</defaultlinkforeground>
<autodisplayverbs type="boolean">false</autodisplayverbs>
</game>
<object name="Chapter One">
<inherit name="editor_room" />
<alias>island</alias>
<look>Dawn on the island. Here is a {object:box} and a {object:key}.</look>
<description>A {object:box} and a {object:key1} is here.</description>
<object name="box">
<inherit name="editor_object" />
<inherit name="container_lockable" />
<inherit name="container_closed" />
<close type="boolean">false</close>
<nokeymessage>You do not have the key. This is the message that displays that.</nokeymessage>
<lockmessage type="string"></lockmessage>
<unlockmessage type="string"></unlockmessage>
<openmsg>The box is now open and you can get stuff.</openmsg>
<hidechildren type="boolean">false</hidechildren>
<canlockopen type="boolean">false</canlockopen>
<isopen type="boolean">false</isopen>
<listchildren type="boolean">false</listchildren>
<listchildrenprefix>how bout this?</listchildrenprefix>
<changeddisplayverbs type="stringlist" />
<displayverbs type="stringlist">
<value>Look at</value>
</displayverbs>
<key type="object">key1</key>
<look type="script">
if (not box.isopen) {
msg ("The box is closed and locked.")
}
else {
msg ("The box is now open and you can get stuff.")
}
</look>
<lock type="script">
if (this.locked) {
msg (DynamicTemplate("AlreadyLocked", this))
}
else if (this.isopen and not this.canlockopen) {
msg (DynamicTemplate("CannotLockOpen", this))
}
else {
if (ListContains(ScopeInventory(), this.key)) {
msg (this.lockmessage)
this.locked = true
}
else {
msg (this.nokeymessage)
}
}
</lock>
<unlock type="script">
if (not this.locked) {
msg (DynamicTemplate("AlreadyUnlocked", this))
}
else {
if (ListContains(ScopeInventory(), this.key)) {
msg (this.unlockmessage)
this.locked = false
if (this.autoopen and not this.isopen) {
TryOpenClose (true, this)
}
}
else {
msg (this.nokeymessage)
}
}
</unlock>
<onunlock type="script">
</onunlock>
<onopen type="script">
</onopen>
<useon type="scriptdictionary" />
</object>
<object name="key1">
<inherit name="editor_object" />
<alias>key</alias>
<take />
<takemsg>You got the dang key.</takemsg>
<inventoryverbs type="stringlist" />
<ontake type="script">
</ontake>
<use type="script">
</use>
<changedtype type="script">
</changedtype>
</object>
<object name="player">
<inherit name="editor_object" />
</object>
</object>
</asl>
michaelsahn
03 Feb 2014, 18:59Ok, I think I'm getting closer.
Using add/change scripts in attributes, I created this:
<changeddisplayverbs type="script">
CloneObject (displayverbs)
if (Got(key1)) {
list add (displayverbs, "unlock")
}
</changeddisplayverbs>
So, if the player gets key1, the displayverbs list should show "unlock".
However, it still does not display when I run it.
Any idea what I am doing wrong?
Thanks again -
MIke
Using add/change scripts in attributes, I created this:
<changeddisplayverbs type="script">
CloneObject (displayverbs)
if (Got(key1)) {
list add (displayverbs, "unlock")
}
</changeddisplayverbs>
So, if the player gets key1, the displayverbs list should show "unlock".
However, it still does not display when I run it.
Any idea what I am doing wrong?
Thanks again -
MIke
Liam315
04 Feb 2014, 00:06The "changedattribute" attribute is a script that runs automatically when it detects that the value of a specific attribute has changed. So the code you stated above will only run once a display verb has been added, which won't happen because it is the very script that adds the display verb.
My suggestion would be:
Get rid of that script entirely.
Go to the inventory tab of the key, add a script in the "after taking the object" section-
In the options tab of the box, add a similar script in the "after unlocking the object" section-
My suggestion would be:
Get rid of that script entirely.
Go to the inventory tab of the key, add a script in the "after taking the object" section-
if (not ListContains(box.displayverbs,"unlock")) {
list add (box.displayverbs,"unlock")
}
In the options tab of the box, add a similar script in the "after unlocking the object" section-
if (ListContains(box.displayverbs,"unlock")) {
list remove (box.displayverbs,"unlock")
}
michaelsahn
04 Feb 2014, 05:11Liam315-
Thanks very much. This works.
Lesson learned: lots of different ways to get the results needed.
Thanks again for your help.
Mike
Thanks very much. This works.
Lesson learned: lots of different ways to get the results needed.
Thanks again for your help.
Mike