another noob question(s)

EdwardVersaii
18 Aug 2013, 18:09
My player in my game can unlock the door to the east, with a key he doesn't have... its just sitting on the table. How do I make it so the player must pick up the key before he can unlock the door? Also while on this topic; when player types command unlock door it gives him the option of using the key OR the table (only two objects in room) this isn't logical at all. How do I make it so only the key appears in the options of unlocking the door? ( do I make the table scenery? even though I have verbs that interact with it such as lie on table? uncomfortable.

Entropic Pen
18 Aug 2013, 18:52
Easy:
1) add a Boolean attribute to the exit called "unlock_with_key" and set it to "false"

2) On the exit, set "Run a script" to true and in the script box set it to "code view" and paste this:


// checks to see if exit was unlocked with key
if (exit.unlocked_with_key = false) {
if (Got(key_object)) {
// player has key
msg ("You unlocked the exit")
exit.unlocked_with_key = true
RemoveObject (key_object)
}
else {
// player does not have key
msg ("You do not have the key")
}
}
else {
// exit is unlocked and player can go through
MoveObject (player, destination)
}

EdwardVersaii
18 Aug 2013, 18:56
I am very new to this- what is a boolean attribute and how do I add it?

**Edit: I am on online version NOT windows version, can I still do what I want to do?**

**Edit #2- I would like to add a new verb such as "kick" to the list of the wooden tables verbs. I added kick and made it display message "ow!" when you did verb kick table, but it is not working when I type kick table as player I just get that it doesn't understand my command. can I make a new verb work? (the verbs work if I use one of quests verbs such as "kiss table" Ow!)**

HegemonKhan
19 Aug 2013, 01:31
I never used the online version, but here's how to do boolean attributes in the offline version with the GUI~Editor:

a "string" type attribute is just a bunch of characters (not all characters are allowed to be used however):

a
4
fjkajf_dlasjd_563445fjioewn
dead

an int (integer) type of attribute is an expression: string = a number amount

object.attribute = (a number amount)

orc.hit_points = 100

a boolean (or a "flag") is an expression: string = true or false

object.attribute = true or false

orc.dead = false
tv.switchedon = false
edward.flying = false
HK.is_awesome = true // :D LOL

how to add boolean attributes to an Object:

orc -> Attributes (Tab) -> Add ->

Name: dead
Type: boolean
Value: false

tv -> Attributes (Tab) -> Add ->

Name: switchedon
Type: boolean
Value: false

edward -> Attributes (Tab) -> Add ->

Name: flying
Type: boolean
Value: false

HK -> Attributes (Tab) -> Add ->

Name: is_awesome
Type: boolean
Value: true // trying to change this to false (via Set object flag script), will result in an error! // (j/k of course) :P LOL

and since a boolean is equal to true or false, we can change what it is set ("Flagged") as:

orc -> Verb (Tab) -> Add ->

Name: fight
Box: RUN AS A SCRIPT

Add a~new script -> Objects -> Set object flag -> // fill it in: Object: orc, [flag name]: dead // this changes it to being: orc.dead=true

~OR~

Add a~new script -> Objects ->Unset object flag -> // fill it in: Object: orc, [flag name]: dead // this changes it to being: orc.dead=false

and lastly, upon doing an "If" (conditional) script, we can check if the boolean is set ("flagged") as: true or false

Add a~new script -> Scripts -> If... -> Add a~new script -> Objects -> Object has flag -> // fill it in: Object: orc, [flag name]: dead // this is checking if orc.dead=true

~OR~

Add a~new script -> Scripts -> If... -> Add a~new script -> Objects -> Object does not have flag -> // fill it in: Object: orc, [flag name]: dead // this is checking if orc.dead=false

so for a conceptual example (I'll be doing this in quasi-code, sorry but it is easier, lol):

<object name="orc">
-> orc.dead=false
</object>

"orc" Object's "fight" Verb script~code block:

if (orc.dead=false) {
-> // you attack the orc
-> if (orc.hit_points <= 0) {
->-> orc.dead=true
-> } else {
->-> // orc attacks you
->-> if (HK.hit_points <= 0) {
->->-> finish
->-> } else {
->->-> do (orc, "fight")
->-> }
-> }
else {
-> msg ("The orc is already dead, silly.")
}

---------------------

P.S.

for better and further explanation on boolean usage, see this thread:

viewtopic.php?f=10&t=3872

enjoy :D

HegemonKhan
19 Aug 2013, 01:48
edward wrote:**Edit #2- I would like to add a new verb such as "kick" to the list of the wooden tables verbs. I added kick and made it display message "ow!" when you did verb kick table, but it is not working when I type kick table as player I just get that it doesn't understand my command. can I make a new verb work? (the verbs work if I use one of quests verbs such as "kiss table" Ow!)**


you have to make a COMMAND (these allow you to type in a verb that you want to do during game play) for your "kick" Verb. But, creating a command might be too confusing for a person new to quest... ask if you need help... or read the tutorial, lol.

Tutorial wiki pages link: http://quest5.net/wiki/Tutorial

VERBS provide the buttons on the right side panels and the hyperlink (the blue link words in the text display) to click on.

since you created the "kick" Verb, you've got to create a Command for it, if you want to be able to type "kick" during game play

the reason the other (default) verbs work by typing them in during game play, is that they're the built-in verbs, already having the Command created for them in the Core coding~game engine by Alex.

jaynabonne
19 Aug 2013, 12:56
Commands and verbs are separate things. Commands have direct script to execute. Verbs are assigned an object attribute, and that attribute is used if the verb matches. You do not need a command for a verb.

What you do need, if you've created a verb, is to then create the appropriate attribute on the desired object.

Here is a sample "kick" verb (this has all been *tested* before posted):

  <verb name="KickIt">
<pattern>kick #object#</pattern>
<property>kick</property>
<defaulttext>You can't kick that</defaulttext>
</verb>

In this case, "property" is the attribute to look for on the target object. And I had a cat in my test game, so here is how you'd set that up to be "kickable":

    <object name="cat">
<inherit name="editor_object" />
<kick type="script">
msg ("The cat says, \"Me-ow!\"")
</kick>
</object>

If you try to kick the cat, if will say: The cat says, "Me-ow!"
For any other object, it will say "You can't kick that."

EdwardVersaii
19 Aug 2013, 14:31
Thanks for all the help everyone, :D . I am still struggling on the attribute thing because I don't think it is supported by the online version, and alas` I am using an apple computer... soo I have an understanding of attributes but I am not able to implement it... :x

HegemonKhan
19 Aug 2013, 14:50
Thanks Jayna! I didn't know the Verb scripting myself in code form, so you can have the <pattern></pattern> for a Verb too, as you can have with a Command (thus allowing for you to be able to type in the verb during game play, hopefully, hehe). I should have looked at the Verb (Element) wiki page more closely, at its attributes, lol. As I didn't know it had the <pattern> attribute. And I presume (if I understand correctly) that the <property> attribute is what connects the Verb's script to the Object's Verb attribute script.

jaynabonne
19 Aug 2013, 16:06
EdwardVersaii wrote:Thanks for all the help everyone, :D . I am still struggling on the attribute thing because I don't think it is supported by the online version, and alas` I am using an apple computer... soo I have an understanding of attributes but I am not able to implement it... :x


I was shocked just now to see that the web editor doesn't support editing attributes. Given how fundamental they are to Quest, that was a bit of a surprise. So my posting wasn't useful for you.

Having said that, I tried adding a "kick" verb to an object - select the object (e.g. "table") and go to "Verbs" for that object and add the verb and its handling there - and it worked. Since I believe you said that didn't work for you, I'm curious what happened. Can you give any more details? You do need to use the actual verb word you want (e.g. "kick").

jaynabonne
19 Aug 2013, 16:10
HegemonKhan wrote:Thanks Jayna! I didn't know the Verb scripting myself in code form, so you can have the <pattern></pattern> for a Verb too, as you can have with a Command (thus allowing for you to be able to type in the verb during game play, hopefully, hehe). I should have looked at the Verb (Element) wiki page more closely, at its attributes, lol. As I didn't know it had the <pattern> attribute. And I presume (if I understand correctly) that the <property> attribute is what connects the Verb's script to the Object's Verb attribute script.


I don't know about the Wiki; I just created a verb. :) But yes, you provide a pattern to be matched for a verb as with a command. In a way, a verb is a specialized form of command - the hard-coded script for that "verby command" just uses the specified object attribute as its standard action instead of one you provide directly as a script yourself. That might not be how it's implemented, but that's how I think about it. ;)

EdwardVersaii
19 Aug 2013, 18:38
Okay this is weird, I created a new verb (insult) and as player I wrote "insult table" and it worked, I then typed "kick table" and it didn't understand my commands!! :x (how do I post pictures to a forum post? that way I can show the heart of my problem

jaynabonne
19 Aug 2013, 19:19
Upload it as an attachment (see the tab below the Submit button next to Options).

HegemonKhan
19 Aug 2013, 23:00
edward wrote:Okay this is weird, I created a new verb (insult) and as player I wrote "insult table" and it worked, I then typed "kick table" and it didn't understand my commands!!


I can't resist a (coding) joke:

do you have a "game.no_physical_violence_allowed=true" boolean attribute in your game? You need to set it to false, via an "Unset Object Flag" script! :D :D :D :D :D

though as a joke, this is a spam post, my apologies, but I just couldn't resist, hehe!