Create a verb
Deckrect
23 Jun 2016, 12:40I was wondering if there is a way to script an object to check a condition (like a boolean or the possession of an object) and create on itself a new verb, adding one of that buttons to itself.
Something like: If the character has a Object:pen, then the Object:book creates a verb to itself name "Autograph" or "Sign".
I am stumbling over the Add Script options, but cannot figure ut a way doing so.
Something like: If the character has a Object:pen, then the Object:book creates a verb to itself name "Autograph" or "Sign".
I am stumbling over the Add Script options, but cannot figure ut a way doing so.
The Pixie
23 Jun 2016, 12:55I would suggesting adding buttons, rather than scripts (and if you add a script, you will also need to add a button).
viewtopic.php?f=18&t=5023
If you do want to add a script, set it up on another object somewhere the player cannot get to, and just assign it to the relevant attribute.
dial.rotate = prototype.rotate_script
viewtopic.php?f=18&t=5023
If you do want to add a script, set it up on another object somewhere the player cannot get to, and just assign it to the relevant attribute.
dial.rotate = prototype.rotate_script
Deckrect
23 Jun 2016, 16:24Ha! Very useful! I just realized I already had this link open, but was looking for something else on it and ignored the important tricks I am looking for now.
I don't understand why Quest has not this sort of options for the GUI!
I don't understand why Quest has not this sort of options for the GUI!
Deckrect
23 Jun 2016, 19:23What happens if I use only AddInventoryVerb(hat, "Wear")
as a room script only once?
as a room script only once?
Deckrect
23 Jun 2016, 19:30Hmmm. I just realized I don't know implementing what I plan doing.
HegemonKhan
24 Jun 2016, 08:14I can think you can do it via these methods (I don't know Pixie's Library, as to what Verb Functions he/she has created for use in it):
1. Turnscript (err, this doesn't use the Object to check itself though, as a 'Turnscript' Element/OBJECT is not an/the 'Object' Element/OBJECT, lol)
~ OR ~
2. the special 'changed' Script Attribute (this does use the Object itself):
http://docs.textadventures.co.uk/quest/ ... anges.html (this explains how it's done via the GUI~Editor)
you simply create a Script Attribute with this name syntax: changedYOUR_ATTRIBUTE'S_NAME
what this does is:
when the Value of "YOUR_ATTRIBUTE'S_NAME" (whatever the Attribute Type) Attribute changes, it'll do/run the scripts you've added to this 'changed' Script Attribute
for example:
-------------
an example:
1. Turnscript (err, this doesn't use the Object to check itself though, as a 'Turnscript' Element/OBJECT is not an/the 'Object' Element/OBJECT, lol)
~ OR ~
2. the special 'changed' Script Attribute (this does use the Object itself):
http://docs.textadventures.co.uk/quest/ ... anges.html (this explains how it's done via the GUI~Editor)
you simply create a Script Attribute with this name syntax: changedYOUR_ATTRIBUTE'S_NAME
what this does is:
when the Value of "YOUR_ATTRIBUTE'S_NAME" (whatever the Attribute Type) Attribute changes, it'll do/run the scripts you've added to this 'changed' Script Attribute
for example:
<object name="player">
<attr name="current_life_integer_attribute" type="int">999</attr>
<attr name="maximum_life_integer_attribute" type="int">999</attr>
<attr name="life_string_attribute" type="string">999/999</attr>
<attr name="statusattributes" type="simplestringdictionary">life_string_attribute = Life: !</attr>
<attr name=changedcurrent_life_integer_attribute" type="script">
if (this.current_life_integer_attribute <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
} else if (this.current_life_integer_attribute > this.maximum_life_integer_attribute) {
this.current_life_integer_attribute = this.maximum_life_integer_attribute
}
this.life_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute
</attr>
<attr name=changedmaximum_life_integer_attribute" type="script">
this.life_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute
</attr>
</object>
-------------
an example:
// you need some kind of scripting to check if the 'whatever' Object contains the 'pen' Object (and/or when you 'take' the 'pen' Object), to set the 'has_pen_boolean_attribute' to 'true', if applicable, and also the reverse too, if no pen (and/or using 'drop' Verb), then to 'false' again.
<object name="player">
<attr name="has_pen_boolean_attribute" type="boolean">false</attr>
<attr name="changedhas_pen_boolean_attribute" type="script">
if (this.has_pen_boolean_attribute and not ListContains (action_button.inventoryverbs, "autograph")) {
list add (action_button.inventoryverbs, "autograph")
} else if (not this.has_pen_boolean_attribute and ListContains (action_button.inventoryverbs, "autograph")) {
list remove (action_button.inventoryverbs, "autograph")
}
</attr>
</object>
<object name="action_button">
<attr name="alias" type="string">actions</attr>
<attr name="parent" type="object">player</attr>
<attr name="autograph" type="script">
// your scripting for doing your autographing of whatever
</attr>
</object>
<verb>
<property>autograph</property>
<pattern>autograph</pattern>
<defaultexpression>You can't autograph that!</defaultexpression>
</verb>
Deckrect
24 Jun 2016, 11:08I am almost understanding. lol
I will try to make it happen by making the room check if player has a given object. If so, another object in the room which cannot be taken will then display a new button.
I will study all you people posted and make a try on this.
I will try to make it happen by making the room check if player has a given object. If so, another object in the room which cannot be taken will then display a new button.
I will study all you people posted and make a try on this.
Deckrect
24 Jun 2016, 11:14By "display a new button " I mean display a new verb.
HegemonKhan
24 Jun 2016, 13:27Verbs (actually are just an Object's Script Attributes, and even more technically they're a sub-type of a Command, though they require a bit extra 'verb' coding if you're writing in the code vs using the GUI~EDitor, as the GUI~Editor does all of the extra code work for you):
creates a 'button' in the 'places and objects' pane and a hyperlink in the big text pane on the left
------
the displayment (for selecting/clicking/choosing) a Verb is done through 'list add/list remove' Scripts/Functions upon the built-in 'displayverbs' and 'inventoryverbs' Stringlist Attributes:
creates a 'button' in the 'places and objects' pane and a hyperlink in the big text pane on the left
------
the displayment (for selecting/clicking/choosing) a Verb is done through 'list add/list remove' Scripts/Functions upon the built-in 'displayverbs' and 'inventoryverbs' Stringlist Attributes:
<object name="blah">
<take /> // this (to the left) is the syntax shorthand for: <attr name="take" type="boolean">true</attr>
<drop /> // this (to the left) is the syntax shorthand for: <attr name="drop" type="boolean">true</attr>
<attr name="look" type="string">You look at the 'blah' object</attr> // 'look' as a String Attribute; GUI~EDitor: 'blah' Object -> 'Setup' Tab -> Description's "Look at" -> [text] option
// or:
<attr name"look" type="script">msg ("You look at the 'blah' object")</attr> // "look" as a Script Attribute; GUI~Editor: 'blah' Object -> 'Setup' Tab -> Description's "Look at" -> [run script] option
// the default is this:
<attr name="displayverbs" type="simplestringlist">look;take</attr>
<attr name="inventoryverbs" type="simplestringlist">look;drop</attr>
</object>
// this is the extra coding that is needed, which the GUI~Editor does for you, when you 'add Verb' :
<verb>
<property>take</property>
<pattern>take</property>
<defaultexpression>You can't take that</defaultexpression>
</verb>
<verb>
<property>look</property>
<pattern>look</property>
<defaultexpression>You can't look at that</defaultexpression>
</verb>
<verb>
<property>drop</property>
<pattern>drop</property>
<defaultexpression>You can't drop that</defaultexpression>
</verb>
Deckrect
25 Jun 2016, 21:08Ahhh... enlightment!