Being able to add new lines to an object that you have in your inventory.

japangirl
13 Dec 2015, 12:15
Hey, I have a very serious and hard-to-word question.

In my game you get this book where you write about what you find, how can I add new lines of text to this book whenever you "write about" (use) it on other objects in the game.

For example
--
>Read Book =
This is your book, you often write your findings down in it.

>Look at Tree = It's a tree.

>Use Book on Tree = You write about the tree in your book.

>Read Book =
This is your book, you often write your findings down in it.

Dear Book, I found a tree.
--

And how can I add more lines to it per item the book is used on? If that makes sense.

I'm not good at code, and it's gibberish to me. I'm using the Web-Browser version of Quest, and I'm a real noob.

OurJud
13 Dec 2015, 12:43
You make things difficult both for yourself and anyone trying to help.

I know code / scripts mean nothing to you (I was the same when I started out) but we can't answer this question without giving you the scripts you'll need. There's no 'easy' answer.

Also, 'use book on [object]' doesn't make any sense, and I can't imagine anyone using this as a command unless you explicitly explain the feature in the game's intro or help files.

However, adding a new line to the player's book, whenever the player has 'looked' at an object could be done with flags.

If you're willing to try and get your head around scripts, I'm sure we can come up with something.

Finally, do yourself a favour and download the desktop version.

japangirl
13 Dec 2015, 12:51
OurJud wrote:You make things difficult both for yourself and anyone trying to help.

I know code / scripts mean nothing to you (I was the same when I started out) but we can't answer this question without giving you the scripts you'll need. There's no 'easy' answer.

Also, 'use book on [object]' doesn't make any sense, and I can't imagine anyone using this as a command unless you explicitly explain the feature in the game's intro or help files.

However, adding a new line to the player's book, whenever the player has 'looked' at an object could be done with flags.

If you're willing to try and get your head around scripts, I'm sure we can come up with something.

Finally, do yourself a favour and download the desktop version.

I'm willing to learn, learning's great!

And I do have the desktop version, just prefer the browser one, I suppose.

So~! What do I need to do?

XanMag
13 Dec 2015, 13:01
The easiest way, I think, is to add a flag whenever you add an entry to the journal. Then, in the read/use journal script just have an if statement to check if that flag is present.

So, use book on tree = "you write about the tree in your journal." Read journal = 'If' object journal has flag 'tree', then print message "dear journal... Blah blah blah." We'll address the alternatives to "use book on tree" later.

If you need clarification, I'll supply code/pics for what to do.

japangirl
13 Dec 2015, 13:14
XanMag wrote:The easiest way, I think, is to add a flag whenever you add an entry to the journal. Then, in the read/use journal script just have an if statement to check if that flag is present.

So, use book on tree = "you write about the tree in your journal." Read journal = 'If' object journal has flag 'tree', then print message "dear journal... Blah blah blah." We'll address the alternatives to "use book on tree" later.

If you need clarification, I'll supply code/pics for what to do.

Here's what I've done, pretty sure I'm doing something wrong here. http://i.imgur.com/voEpU2L.png?1

XanMag
13 Dec 2015, 14:07
Whoa. The name of the flag should be something simple. It's only a bookmark or a reference for the code to refer back to. You should not type any kind of message in there at all. One word. And I'm very confused as to your layout. You have that stuff under your verbs? Also, I 100% agree with OJ. The download of Quest is way better than the online version.

Think of all your flags as a 'to do' list. If you have a flag set, it's like having 'done' that to do item. Then, your game can check to see if that item is done and you can script accordingly.

Looks like OJ is doing a good job explaining below.

OurJud
13 Dec 2015, 14:08
Let's do this in stages.

1. Right click 'game' at the top of the left hand pane, and choose 'Add a command'.
2. Use the UI to make it look like this (remember to choose 'Add a script' from the dropdown menu.)

command.jpg


3. If you would rather use script code, click on the second icon from the right in the UI (I've circled it in red) and add this:

msg ("This is your journal. Any notes can be seen below.")
if (GetBoolean(player, "tree")) {
msg ("I saw a tree today.")
}
if (GetBoolean(player, "horse")) {
msg ("I saw a horse today.")
}
if (GetBoolean(player, "castle")) {
msg ("I saw a castle today.")
}

OurJud
13 Dec 2015, 14:13
Now, In the room where your objects are, click on the object and make the UI look like this:

object.jpg


Here's the script code if you would rather use it (click the icon I've circled to add it)

msg ("It's a tree.")
SetObjectFlagOn (player, "tree")


So this is what you must do with each object that you want added to the journal. You must also go back to the 'read book' command in game and add another 'if' statement for it. Just use the sctipt code view and keep adding this after the last one:

if (GetBoolean(player, "castle")) {
msg ("I saw a castle today.")
}


Just change the name of the object each time.

ADDITIONAL NOTES:


Even if you don't use the script, study it and understand what it's doing.

In the case of the command script:

msg ("This is your journal. Any notes can be seen below.")
if (GetBoolean(player, "tree")) {
msg ("I saw a tree today.")
}


In plain English, is saying, 'Print this message, then check to see if the player has a flag, if he does, then print this message.'

The object script

msg ("It's a tree.")
SetObjectFlagOn (player, "tree")

is saying, "Print this message, then add a flag to the player so that the command script knows they've seen the object."

japangirl
13 Dec 2015, 15:07
Okay, that makes sense to me and I tried to follow the instructions.

Here's what I got: http://imgur.com/a/U7TVS

Whenever I try to read the book, it says "I can't see that. (book Your Very Own Book)"

Gonna work on this later today though, it's currently 2am here.

OurJud
13 Dec 2015, 16:09
I suspect it's clashing with the verb you have for 'read book'.

japangirl
13 Dec 2015, 22:44
Nah, still says that it won't work whenever I write about the tree.

japangirl
14 Dec 2015, 02:05
Oh, lovely. The website has decided to delete my game and the game that got published. Won't allow me to upload the saved one either. Not exactly happy right now.

OurJud
14 Dec 2015, 08:55
japangirl wrote:Nah, still says that it won't work whenever I write about the tree.

That's probably because you're typing something for which there's no command set.

Whatever it is you're typing that won't work, add it as a command in the way I showed you.

japangirl wrote:Oh, lovely. The website has decided to delete my game and the game that got published. Won't allow me to upload the saved one either. Not exactly happy right now.

Which is why I told you to use the desktop version. If you use the desktop version you always have a copy stored on your own machine.

japangirl
14 Dec 2015, 09:33
OurJud wrote:

"japangirl"

Nah, still says that it won't work whenever I write about the tree.


That's probably because you're typing something for which there's no command set.

Whatever it is you're typing that won't work, add it as a command in the way I showed you.

japangirl wrote:Oh, lovely. The website has decided to delete my game and the game that got published. Won't allow me to upload the saved one either. Not exactly happy right now.

Which is why I told you to use the desktop version. If you use the desktop version you always have a copy stored on your own machine.


I've saved it, but the site isn't allowing me to upload it. It's saying that it's already been uploaded by another user ID, which I don't quite understand since I haven't given it to anyone.

Alex
14 Dec 2015, 10:45
Sounds like you've set up two accounts.

The Pixie
14 Dec 2015, 10:46
Open the game up in Quest; you should be on the Setup tab of the game object. A couple of inches down on the far right is a button, "Generate". Click that, and your game will get a new ID, and you should be able to upload it.

japangirl
14 Dec 2015, 13:44
Alex wrote:Sounds like you've set up two accounts.

I don't think that I did though, is there any way for you to check on your end?

OurJud
14 Dec 2015, 13:47
japangirl wrote:

"Alex"

Sounds like you've set up two accounts.


I don't think that I did though, is there any way for you to check on your end?


Have you even tried what The Pixie suggests?

japangirl
14 Dec 2015, 13:51
OurJud wrote:

"japangirl"

[quote="Alex"]Sounds like you've set up two accounts.


I don't think that I did though, is there any way for you to check on your end?


Have you even tried what The Pixie suggests?[/quote]
Trying it right now, the site is currently lagging badly for me. I think that it's because of my connection or something.

EDIT: Yup! It worked, cheers Pixie and everyone else. So how does one get this journal working?

OurJud
14 Dec 2015, 13:58
japangirl wrote:So how does one get this journal working?

The way I showed you on the previous page. I can confirm it works, so if it doesn't for you, you are going wrong somewhere along the line. I still maintain your verb for 'read book' is conflicting with the command for same, so try deleting the verb see what happens.

Remember that my solution doesn't include any commands for things like 'write in journal' or 'use journal on tree', so if you want these you'll have to add them in the way I showed you.

japangirl
14 Dec 2015, 14:23
OurJud wrote:

"japangirl"

So how does one get this journal working?


The way I showed you on the previous page. I can confirm it works, so if it doesn't for you, you are going wrong somewhere along the line. I still maintain your verb for 'read book' is conflicting with the command for same, so try deleting the verb see what happens.

Remember that my solution doesn't include any commands for things like 'write in journal' or 'use journal on tree', so if you want these you'll have to add them in the way I showed you.


Deleted the verb, still isn't showing any more text on the book. When I "write about" the Tree, it simply says "That Doesn't Work".

Is it possible that the Ask/Tell feature is bugging it up? I've copied it practically exactly: http://imgur.com/a/L1dEi

OurJud
14 Dec 2015, 14:49
Do you have a command set for 'write about' ??

All my script does is add a note to the journal whenever a player 'looks' or 'x' an object.

So if the locations says:

You are in a field. There is a horse here.
> x horse

It's a big black mare.


The book when the player types 'read book' will say:

This is your journal.

I saw a horse today.


The script does NOT cater for 'write in book about horse' or 'use book on horse', or any other such command.

japangirl
15 Dec 2015, 05:13
Setting a command for "write about" is just adding write about to read book; open book; read journal; open journal; use book; use journal; , right?

I should probably let you know that I'm primarily using the mouse to play my game by just clicking on the buttons to the right of the player.

The Pixie
15 Dec 2015, 08:29
I have only just realised that "write about" would be a verb on the tree, not the book. Okay, so here is how I would do it. I would use verbs, rather than commands. One reasonis that I like verbs, a more important reason is that the READ verb is built in and might be causing problems with your command.

So you need a READ verb on the book, and a WRITE ABOUT verb on the tree and everything else. You also need an attribute on the book to save its content. We will do that first (and you need to be working off-line to do this).

The content

Go to the Attributes tab of the book. The lower half lists attributes already set, click the Add button above that (there is another Add button at the top; avoid that one), and type in "content" (no quotes). Right at the bottom you will see it now says "String", and there is a text box below that. Type the starting text in there, perhaps. "Today I am starting my diary!" (no quotes).

The READ verb will allow the player to see this string, and the WRITE ABOUT verb will add more text to it.

The READ verb

Now go to the Verbs tab, click on the Add button, and type in "read" (no quotes) (because read is already built-in you will see it gets listed as soon as you type the "r"). At the bottom, where it says "Print a message", change that to "Run a script". Click "Add new script", and select "Print a message" from the list. Change "Message" to "Expression", and type in "this.content" (no quotes; note that some get added by default, make sure you delete them).

Now start your game, and see what happens when you read the book.

The WRITE ABOUT verb

Now go to the Verb tab of your tree object, click Add and type in "write about" (no quotes). At the bottom, where it says "Print a message", change that to "Run a script". Where it says "Print a message", change that to "Run a script". Click "Add new script", and select "Print a message" from the list. In the text box, type in "You write about it" (no quotes).

Click "Add new script" again, and this time select "Set an object's attribute". You get a few things to fill in. The first is already set to "name", leave it. The second is a drop-down list; select your book from the list of objects. The third is labelled Attribute. Type in "content" and just for once you need the double quotes. The last is labelled Value, and here you type in what you want to appear in your book, plus other stuff, something like this (keep the double quotes):
book.content +  "<br/>Dear Book, I found a tree."

I am assuming your book is called "book", if not, you will need to change the above accordingly.

The book.content part is whatever is already in the book. You need that because you want to add to what is already there. The <br/> bit will put it on a new line (and you might want to put two in).

Play the game and see if it works. If it does, you will need to do the WRITE ABOUT thing for every other object in your game.

READ again

You can make your journal a bit more fancy using HTML. Change the text in Print - expression to this:
"<i>" + this.content + "</i>"

... and the text will be in italic. Or this:
"<span style=\"color:blue;font-style:italic;\">" + this.content + "</span>"

.. and it will be in blue and italic.

japangirl
15 Dec 2015, 14:08
Cheers! That worked well, however I can still Write About objects without having the book on the player. I tested it out on two objects and one replaced the other in the "read" results. How can I have it shows all of what you've written about?

The Pixie
15 Dec 2015, 14:55
I forgot about checking if you have the book. Also, I forgot to check if you have already written in the book. But it should be adding to the content, not replacing it.

Go to the Verbs tab of your tree, select "write on", so the script appears at the bottom. Click the seventh icon, "Code view". Replace the text with this:
if (not book.parent = player) {
msg ("You have nothing to write about it in")
}
else if (GetBoolean(this, "writtenabout")) {
msg ("You have already write about it")
}
else {
msg ("You write about it")
this.writtenabout = true
book.content = book.content + "<br/>Dear Book, I found a tree."
}

You will need to paste that in to every object that can be written about, but the only bit you need to change is where it says Dear Book, I found a tree

In case you are interested...

The code uses if/if else/else blocks to test various failing cases, and only if no failing case is found it actually does something. The first block checks if the player has the book (i.e., the player is the parent of the book). The second block checks if the writtenabout flag has been set on this object. If it gets to the third block we are good to go, and the book gets updated, and we flag that we have done it for this object.

XanMag
15 Dec 2015, 15:09
Or, simpler yet... just make it so you cannot drop the book. That way you always have it.

The Pixie
15 Dec 2015, 15:16
That is definitely worth considering. I did that in Deeper; the player has a light source he cannot drop, so I avoided any issues about the room being dark.

japangirl
16 Dec 2015, 04:56
The Pixie wrote:I forgot about checking if you have the book. Also, I forgot to check if you have already written in the book. But it should be adding to the content, not replacing it.

Go to the Verbs tab of your tree, select "write on", so the script appears at the bottom. Click the seventh icon, "Code view". Replace the text with this:
if (not book.parent = player) {
msg ("You have nothing to write about it in")
}
else if (GetBoolean(this, "writtenabout")) {
msg ("You have already write about it")
}
else {
msg ("You write about it")
this.writtenabout = true
book.content = book.content + "<br/>Dear Book, I found a tree."
}

You will need to paste that in to every object that can be written about, but the only bit you need to change is where it says Dear Book, I found a tree

In case you are interested...

The code uses if/if else/else blocks to test various failing cases, and only if no failing case is found it actually does something. The first block checks if the player has the book (i.e., the player is the parent of the book). The second block checks if the writtenabout flag has been set on this object. If it gets to the third block we are good to go, and the book gets updated, and we flag that we have done it for this object.

Dude! I love you! Thank you so much!!

japangirl
16 Dec 2015, 14:35
Is it possible to set a random percentage of something happening? I can't seem to find it.

OurJud
16 Dec 2015, 15:04
japangirl wrote:Is it possible to set a random percentage of something happening? I can't seem to find it.

If this is a separate question, best start a new thread otherwise it will get missed. Anyone following this thread will consider it closed as your original question has been answered.

And if you do, you'll probably need to add far more detail before anyone could begin to answer.

HegemonKhan
17 Dec 2015, 03:29
japangirl wrote:Is it possible to set a random percentage of something happening? I can't seem to find it.


http://docs.textadventures.co.uk/quest/ ... hance.html (PercentChance)

to do this via the GUI~Editor:

run as script -> add new script -> output (I think) -> ~ 'call function' Script -> (see below)

Name (text box): RandomChance
// you type in the NAME of the Function, to call the Function, just like you say someone's name to call (get their attention) them, lol. HK: "Hey Joe, you want to hang out playing games over the weekend?" ~ HK has just called the Function 'Joe' (getting Joe's attention for the question about hanging out over the weekend: The Function 'Joe' will output either: sure~yes or no~sorry), lol. The 'Joe' Function's Parameter(s) would be the question to him, of if he wants to hang out and play games over the weekend.

Parameters (big 'add' box): (this should enable you to set your number for its percent chance as just a single added parameter ~ I've never tried doing this though with the GUI~Editor)

---------

and the other 3 Randomization Functions:

(all Functions can be done in the GUI~Editor, through the 'call function' Script and adding in the parameters if needed)

http://docs.textadventures.co.uk/quest/ ... eroll.html (DiceRoll)

http://docs.textadventures.co.uk/quest/ ... omint.html (GetRandomInt)
http://docs.textadventures.co.uk/quest/ ... ouble.html (GetRandomDouble)

------

ask if you need help with anything