Journals

Anonynn
I have a journal object.

And I would like for the player to type.... note or Note ...and be able to write whatever they want in it.

I know there is a journal library made by Pixie, but I don't think it works anymore, at least I couldn't get it to work. I also don't want it recording all the pages of the game. I just want it to record what the player types after "Note"

Does that make sense?

XanMag
That makes perfect sense. It's an easy task if you control what the player can input in the journal. After an event just raise a flag. Add Ifs/if else statements for each flag that prints desired message when journal is read.

But, obviously, that is not what you want. It would be a really neat little feature to be able to do this with Quest. I toyed with it and did a little research, but made ZERO headway. I'm guessing you would need to give their inputted text an ID tag and recall the ID tag when the journal was read with something like getElementById... but I can't figure out how to link user input to an ID tag. I'm sure a quality coder would have no problem helping you out with this. I am eager to see how this would be done because it uses code I have no idea how to implement or have run across using Quest. Also, a problem you might encounter with freedom of input is the need/want to remove player input from the journal as well! YIKES! I too tried to download/open Pixie's journal library and it failed to open in Quest.

Then again... you can always force the player to resort back to their Zork days and get out the old fashioned pencil and paper for taking notes and referencing! GOOD LUCK!!

HegemonKhan
look into using lists~dictionaries ... for making a journal

lists can store~hold text~strings (words, sentences, paragraphs), so you can use 'get input', typing whatever you want, and storing it as an item in a list. you can also retrieve that item, add an item, remove an item, etc etc etc

dictionaries are even better, as you got two entries~parameters ('get input' for each if you want), enabled you to hold an indentifying subject~topic (or even sentences nd paragraphs too, not just words), as well as your 'message' (text~strings: words, sentences, and paragraphs). Has all of the same features~uses~capabilities as lists.

also, lists~dictionaries can hold lists~dictionaries as their items (along with using nested 'for~foreach' ), so you can implement 'pages', and 'items' on each of those 'pages'.

-------

reading a 1000 page intro java book (in trying to get ahead for classes starting later this month) is really helping me expand my code+design ability, it gives me lots of code examples and explains stuff... though Java's internal setup's terminology~structure~etc, which makes the user-level terminology~structure~design~etc extremely confusing... though thankfully it is actually a lot like quest (as I slowly understand java better) ... if it wasn't for quest... there's no way I'd be understanding Java as I am (albiet strugglingly), quest really does things so much better, at least at the user level, compared to Java... finally after 650 pages (out of the 1000), I think I finally understand (I hope) 'referance variable creates a memory address location' vs an 'object instance creation', in regards to its 'pointing~referencing', laughs. This memory ~ memory space and address location and etc, machine~assembly language, stuff still greatly confuses me, sighs.

trying to get 1000 page java book read in 10 days, and then another ~1000 page C++ book read in another 10 days... before classes start... I HATE reading practically non-stop... the numerous code examples are extremely helpful... but oh is it also so boring to read through code example after code example after code example ...

I think I'm really going to have a hard time doing Java and C++, I can see myself getting the two of them (+ quest's XML + python + JS) confused, constantly, laughs... I'm hoping that quick lookups at the code will alleviate this issue...

TM123
How's this? Each note is on a separate "page." Reading flips through the pages.

<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Journal">
<gameid>31c8b0d3-5c93-4b12-ae5c-b6a599c6e852</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="journal">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>journal</alias>
<look>This is a 3" x 5" notebook with metal covers. The pages are a strange pliable substance which cannot be torn. You could 'note' things in it.</look>
<note type="script">
// this is a comment
get input {
msg ("This is the result: " + result)
}
</note>
<alt type="stringlist">
<value>notebook</value>
</alt>
<take />
<pages type="stringlist" />
<currentpage type="int">-1</currentpage>
<feature_container />
<read type="script"><![CDATA[
if (journal.isopen) {
journal.currentpage = journal.currentpage + 1
if (journal.currentpage > ListCount(journal.pages) - 1) {
journal.currentpage = 0
}
if (journal.currentpage <= ListCount(journal.pages) - 1) {
msg (StringListItem(journal.pages, journal.currentpage))
}
else {
msg ("There are no notes in the journal.")
}
}
else {
msg ("The journal is closed.")
}
]]></read>
<openscript type="script">
journal.currentpage = -1
HelperOpenObject (journal)
msg ("You open it.")
</openscript>
</object>
<object name="pencil">
<inherit name="editor_object" />
<alias>pencil</alias>
<take />
</object>
</object>
<command name="note">
<pattern>note</pattern>
<script>
if (Got(journal)) {
if (Got(pencil)) {
if (journal.isopen) {
msg ("Enter your note")
get input {
list add (journal.pages, result)
}
}
else {
msg ("The journal is closed.")
}
}
else {
msg ("You need something to write with.")
}
}
else {
msg ("I don't understand your command.")
}
</script>
</command>
</asl>

HegemonKhan
very nice TM123 !!!

excellently done for its current state (and so fast too, you seem like a good coder, the more good coders here the better, hehe. That way we pester each of you less with our questions or needing help, laughs)

--------

obviously, people may~will want some or much more features with it (such as being able to select what page and what item to see~read, previous page input~goto, first page input~goto, next page input~goto, last page input~goto, next X page input~goto, previous X page input~goto, organizational structuring of your inputs~notes, to do quests~missions~tasks, completed quests~missions~tasks, etc etc etc) ... and~or a GUI with it, laughs. This is obviously a ton more work, to implement all of these additional features, to make a fully functional diary~journal~notebook. This would be a fully functional journal~diary~notebook~log~records, as comparing to a more skeleton journal~diary~notebook~log~record that you quickly created for use.

TM123
Here's another using a dictionary instead of a list.
Features:
32 pages.
hints on how to use in the description.
Commands:
open, close
turn journal to page #
note -- appends an entry to the current page, entries separated by a <br>
erase journal -- erases the last entry on the current page
read journal -- read the current page

maybe each page could have a sub-dictionary so that each entry would have a header and could be erased/appended to independently. And a highlight pen...

<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Journal">
<gameid>31c8b0d3-5c93-4b12-ae5c-b6a599c6e852</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<start type="script">
firsttime {
for (i, 1, 32, 1) {
dictionary add (journal.pages2, "Page " + i, "")
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="journal">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>journal</alias>
<look>This is a 3" x 5" notebook with metal covers. The 32 pages are a strange pliable substance which cannot be torn. It looks like you could turn the journal to page #, and you could 'note' things in it.</look>
<alt type="stringlist">
<value>notebook</value>
</alt>
<take />
<currentpage type="int">1</currentpage>
<feature_container />
<read type="script">
if (journal.isopen) {
msg ("Page " + journal.currentpage)
msg (StringDictionaryItem(journal.pages2, "Page " + journal.currentpage))
}
else {
msg ("The journal is closed.")
}
</read>
<openscript type="script">
journal.currentpage = 1
HelperOpenObject (journal)
msg ("You open it.")
</openscript>
<pages2 type="stringdictionary" />
<erase type="script"><![CDATA[
blah = 1
if (Got(pencil)) {
blah = blah + 2
}
if (journal.isopen) {
blah = blah + 4
}
switch (blah) {
case (1, 5) {
msg ("You need something to erase with.")
}
case (3) {
msg ("The journal is closed.")
}
case (7) {
newtextlist = Split(StringDictionaryItem(journal.pages2, "Page " + journal.currentpage), "<br>")
list remove (newtextlist, StringListItem (newtextlist, ListCount(newtextlist) - 1))
if (ListCount(newtextlist) > 0) {
newtext = Join (newtextlist, "<br>")
}
else {
newtext = ""
}
dictionary remove (journal.pages2, "Page " + journal.currentpage)
dictionary add (journal.pages2, "Page " + journal.currentpage, newtext)
msg ("OK")
}
}
]]></erase>
</object>
<object name="pencil">
<inherit name="editor_object" />
<alias>pencil</alias>
<take />
<look>This is a sharp #2 pencil with an eraser.</look>
</object>
</object>
<command name="note">
<pattern>note</pattern>
<script><![CDATA[
blah = 0
if (Got(journal)) {
blah = 1
}
if (Got(pencil)) {
blah = blah + 2
}
if (journal.isopen) {
blah = blah + 4
}
switch (blah) {
case (0, 4) {
msg ("I don't understand your command.")
}
case (1, 5) {
msg ("You need something to write with.")
}
case (2, 6) {
msg ("You need something to write on.")
}
case (3) {
msg ("The journal is closed.")
}
case (7) {
msg ("Enter your note.")
get input {
newtext = StringDictionaryItem(journal.pages2, "Page " + journal.currentpage) + "<br>" + result
dictionary remove (journal.pages2, "Page " + journal.currentpage)
dictionary add (journal.pages2, "Page " + journal.currentpage, newtext)
msg ("OK")
}
}
}
]]></script>
</command>
<command name="turnjournalpage">
<pattern>turn journal to page #textpage#</pattern>
<script><![CDATA[
if (Got(journal)) {
blah = toint(textpage)
if (blah > 0 and blah < 33) {
HelperOpenObject (journal)
journal.currentpage = toint(textpage)
msg ("You turn to page " + (blah))
}
else {
msg ("There is no page " + blah)
}
}
else {
msg ("I don't understand your command.")
}
]]></script>
</command>
<verb>
<property>erase</property>
<pattern>erase</pattern>
<defaultexpression>"You can't erase " + object.article + "."</defaultexpression>
</verb>
</asl>

Anonynn
Wow! I'll have to give those a shot. Thanks a lot TMI! Appreciate it.

I tried out the first code (It's a little more complicated than I needed) and there seems to be an issue with it working and not lining up "lines blah blah with blah blah"

I don't really need it to be complicated. Just the journal object (no pencil or pen required) with the player being able to write in entries with one big long page that doesn't need to be turned.


HK keep up the hard work too! I hope classes are going okay so far.

HegemonKhan
Wow, thanks again Tm123, I didn't mean you had to create a more full functional code, just that people will want one... that someone may make in the future for them, so thanks for doing so! If I had the time, I could maybe have done it, though it'd take me a lot longer to craft+bug fix, and would be a lot more messy (poor) coded, lol. Problem is that I got a lot of other things in coding and~or in learning to code, to do... sighs. Making a journal would have just been anothing thing added onto my 'to do' list, in learning to code more and inch towards making a game, laughs.

------

off-topic

@Neonayon:

classes haven't started yet, I'm trying to get what work I can do (such as reading...ugh) done, ahead of the classes' start date (late this month: ~ 26th), and all of the other stuff I need to do too (payments and etc).

Anonynn
I don't suppose you all could break that down? It's hard to grasp.

TM123
OK, here's a bare minimum journal.
Make an object named "journal."
add a string attribute: "text"
add a verb: "note"
add the verb script:
msg ("Enter your note.")
get input {
journal.text = journal.text + "<br>" + result
}
msg ("OK")

That appends the input ("result") onto the "text" attribute with a "<br>"
add verb: "read"
add the verb script:
msg (journal.text)


and that's it.

Even simpler: skip the attribute, skip the read verb and script. Change the note script from "journal.text" to "journal.look" -- to read it just "look at journal" I don't think you can get any simpler.



And here's version 1.1 with an improved page turning command - the other didn't check if the input was an integer. Now you can "turn to page #" "turn page" and "turn back" along with a few variations -- all with one regexp which won't match "turn knob" or "turn into a werewolf."

<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Journal">
<gameid>31c8b0d3-5c93-4b12-ae5c-b6a599c6e852</gameid>
<version>1.1</version>
<firstpublished>2015</firstpublished>
<start type="script">
firsttime {
for (i, 1, 32, 1) {
dictionary add (journal.pages, "Page " + i, "")
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="journal">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>journal</alias>
<look>This is a 3" x 5" notebook with metal covers. The 32 pages are a strange pliable substance which cannot be torn. It looks like you could turn the journal to page #, and you could 'note' things in it.</look>
<alt type="stringlist">
<value>notebook</value>
</alt>
<take />
<currentpage type="int">1</currentpage>
<feature_container />
<pages type="stringdictionary" />
<read type="script">
if (journal.isopen) {
msg ("Page " + journal.currentpage)
msg (StringDictionaryItem(journal.pages, "Page " + journal.currentpage))
}
else {
msg ("The journal is closed.")
}
</read>
<openscript type="script">
journal.currentpage = 1
HelperOpenObject (journal)
msg ("You open it.")
</openscript>
<erase type="script"><![CDATA[
blah = 1
if (Got(pencil)) {
blah = blah + 2
}
if (journal.isopen) {
blah = blah + 4
}
switch (blah) {
case (1, 5) {
msg ("You need something to erase with.")
}
case (3) {
msg ("The journal is closed.")
}
case (7) {
newtextlist = Split(StringDictionaryItem(journal.pages, "Page " + journal.currentpage), "<br>")
list remove (newtextlist, StringListItem (newtextlist, ListCount(newtextlist) - 1))
if (ListCount(newtextlist) > 0) {
newtext = Join (newtextlist, "<br>")
}
else {
newtext = ""
}
dictionary remove (journal.pages, "Page " + journal.currentpage)
dictionary add (journal.pages, "Page " + journal.currentpage, newtext)
msg ("OK")
}
}
]]></erase>
</object>
<object name="pencil">
<inherit name="editor_object" />
<alias>pencil</alias>
<take />
<look>This is a sharp #2 pencil with an eraser.</look>
</object>
</object>
<command name="note">
<pattern>note</pattern>
<script><![CDATA[
blah = 0
if (Got(journal)) {
blah = 1
}
if (Got(pencil)) {
blah = blah + 2
}
if (journal.isopen) {
blah = blah + 4
}
switch (blah) {
case (0, 4) {
msg ("I don't understand your command.")
}
case (1, 5) {
msg ("You need something to write with.")
}
case (2, 6) {
msg ("You need something to write on.")
}
case (3) {
msg ("The journal is closed.")
}
case (7) {
msg ("Enter your note.")
get input {
newtext = StringDictionaryItem(journal.pages, "Page " + journal.currentpage) + "<br>" + result
dictionary remove (journal.pages, "Page " + journal.currentpage)
dictionary add (journal.pages, "Page " + journal.currentpage, newtext)
msg ("OK")
}
}
}
]]></script>
</command>
<command name="turnjournalpage">
<pattern type="string"><![CDATA[^turn (the journal |journal )?to page (?<text>\d+)$|^turn (the |a )?(?<text>page)$|^turn (the page |a page |page )?(?<text>back)$]]></pattern>
<script><![CDATA[
switch (true) {
case (IsInt (text)) {
blah = toint(text)
if (blah > 0 and blah < 33) {
HelperOpenObject (journal)
journal.currentpage = blah
msg ("You turn to page " + blah)
}
else {
msg ("There is no page " + blah)
}
}
case (text = "page") {
if (journal.isopen) {
journal.currentpage = journal.currentpage + 1
if (journal.currentpage = 33) {
journal.currentpage = 1
}
msg ("You turn to page " + journal.currentpage)
}
else {
msg ("The journal is closed.")
}
}
case (text = "back") {
if (journal.isopen) {
journal.currentpage = journal.currentpage - 1
if (journal.currentpage = 0) {
journal.currentpage = 32
}
msg ("You turn to page " + journal.currentpage)
}
else {
msg ("The journal is closed.")
}
}
default {
msg ("I don't understand your command.")
}
}
]]></script>
</command>
<verb>
<property>erase</property>
<pattern>erase</pattern>
<defaultexpression>"You can't erase " + object.article + "."</defaultexpression>
</verb>
</asl>

Anonynn
Thanks! The simple journal thing works great! I appreciate that TMI, and HK. Good to see you again too Xan!

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

Support

Forums