Journal / notebook issues.

DonJohn
17 Jul 2018, 09:45

I have a problem making the journal as it is in the tourtorial.
I follow the steps there but get the same message.

"Error running script: Error compiling expression 'journal.entries': RootExpressionElement: Cannot convert type 'QuestList`1' to expression result of 'Boolean'"

What have I missed?

Bare in mind that im farely new to this so please be kind


mrangel
17 Jul 2018, 13:35

Do you mean this tutorial: http://docs.textadventures.co.uk/quest/keeping_a_journal.html ?

If so, I'd guess that you have the line if (journal.entries) { somewhere.

That doesn't appear in any of the example code. So if one of your scripts contains it, try thinking about what should be there. If you're not sure, I'm sure someone will be happy to help. Just show us the code that's causing the problem.


DonJohn
18 Jul 2018, 06:00

Yes that is the one.
I follow the instructions there step by step. but get this message
"Could not set value 'ListCount(this' - The number of opening brackets "(" does not match the number of closing brackets ")"."


hegemonkhan
18 Jul 2018, 07:34

Are you making a 'Text Adventure' or 'Game Book' game?

Are you making your game offline or online?

(also, you might still have the 'simple mode' toggled on - if quest still has this, make sure you toggle this off, to enable all of the features)

if your game is small and you don't mind posting your entire game code:

right click on your 'NAME_OF_GAME.aslx' game file (if doing online, you got to download it, and then unzip, using winrar, winzip, etc softwares/programs, the 'NAME_OF_GAME.quest' file, to get at your 'NAME_OF_GAME.aslx' game file), select to 'open' it, then choose a text editor software (notepad, wordpad, Apple: text editor, notepad++, etc), which will open up into your entire game code, so highlight all of it, copy it, and then post it here in a code box, like this:

m```
(paste your code here)
m```

but without the m's in front, producing this:

(paste your code here)

otherwise, if you want to, you can try to tract down the code errors yourself and fix them on your own...


IMPORTANT, DO THIS FIRST: make a backup copy of your 'NAME_OF_GAME.aslx' game file


then search through your code looking for a line/segment that has 'ListCount (LIST)', and starting from there, move outwards (left and right), and check to the left and right sides of it, making sure that if you got a '(' on the left side, you got a ')' on the right side too (and vice versa), the number of '(' and ')' must equal each other


for more explanation, this is the syntax for a Function:

NAME_OF_FUNCTION (XXX) // see how we got one '(' and one ')', they match up

if (XXX) // parenthesis DO match up

if XXX) // ERROR: missing the left '('
if (XXX // ERROR: missing the right ')'
if ((XXX) // ERROR: missing a right ')' or got an extra left '('
if (XXX)) // ERROR: missing a left '(' or got an extra right ')'


now, usually the 'ListCount (XXX)' Function is used like this (Functions nested within Functions), an example:

example_stringlist_variable = split ("red;blue;yellow", ";")

string_variable = StringListItem (example_stringlist_variable, GetRandomInt (0, ListCount (example_stringlist_variable) - 1))

// there's three '(' and three ')', and also they're in their correct syntax placements too (which is harder to explain/understand), so they match up in quantity (easy to check-count-them-up/understand, lol)


now this (the code line in the above section) is nice and compact, but it's harder to read/understand and to make sure you got matching parenthesis (and in their correct syntax placements), as compared to separating them, like so:

// just to see it conceptually better:

example_stringlist_variable = split

(

  "red;blue;yellow", ";"

)

string_variable = StringListItem

(

  example_stringlist_variable, GetRandomInt

  (

    0, ListCount

    (

      example_stringlist_variable

    )

    - 1

  )

)

// here's its actual working breakdown/separation:

example_stringlist_variable = split ("red;blue;yellow", ";")

list_count_integer_variable = ListCount (example_stringlist_variable)

last_index_item_integer_variable = list_count_integer_variable - 1

random_viable_list_item_index_number_integer_variable = GetRandomInt (0, last_index_item_integer_variable)

string_variable = StringListItem (example_stringlist_variable, random_list_viable_integer_variable)

also, 'ListCount (XXX)' is often used like this too:

// replace my 'LIST' with an actual List Attribute (NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE) or List Variable (NAME_OF_LIST_Variable)

if (ListCount (LIST) = 0) {
  // scripting
} else {
  // scripting
}

mrangel
18 Jul 2018, 08:32

I follow the instructions there step by step. but get this message

Can you paste your code here? To make it display properly so we can see it, paste it with three backticks (`) before and after.

```
code goes here
```

It's hard to say what's wrong with your code, without being able to look at the code.

Also, when does it give the error message? Is it as soon as you start the game? When you try to read the journal? When you try to write in it?


DonJohn
18 Jul 2018, 09:36

Right now i am doing it online becouse I am not home so I cannot download the offline version (which i will when I get back)

I am using an ipad (if that matters)

I have checked so simple mode is not ticked.

Right now I am just playing around with it so there is no actuall game code really to show.

The code that im putting in is:

journal.entries = NewStringList()
this is what i put in the games start script

    msg ("You have nothing written in your journal.")
  }
  else {
    msg ("You look at your journal:")
    foreach (s, this.entries) {
      msg (s)
    }
  } 

That is what i put in as a read verb for the journal

It says when i have putted it in as a verb so i guess that there is the thing i am doing something wrong


mrangel
18 Jul 2018, 12:37

That code does not contain the expression ListCount(this quoted in your error message.

In the tutorial, the read verb starts with the line if (ListCount(this.entries) = 0) {. I guess you missed that out when you copied your code.
There are two (s and two )s in that line.

The error says that you have a line containing the words ListCount(this, where the number of ( and ) does not match. Maybe you missed out one of the brackets?

  • Something like if (ListCount(this.entries = 0) {
  • or if (ListCount(this.entries) = 0 {
  • or if ListCount(this.entries) = 0) {

Look carefully at the expression, and make sure there aren't any brackets missing.

(once you've fixed it, you might need to press "save" and then refresh the browser. Because the online editor will sometimes keep on showing you an error message even after you fixed it)


DonJohn
18 Jul 2018, 15:13

I do not know if it is the heat here that makes me slow or if i am just born that way but i have been trying it, going thru the scripts and reading here over and over but i still get the same

Yes I missed that "if" part when i copied it to here but i been having it in the verb all along. If you guys look at the script from the tourtorial can you see anything wrong?

I might be wrong but there is one more ) then ( and if it is where should the ( go?
I am really lost here

I know that you probaly banging you head against the desk now becouse i am not getting this but I do apreciate all you patience and support

if (ListCount(this.entries) = 0) {
    msg ("You have nothing written in your journal.")
  }
  else {
    msg ("You look at your journal:")
    foreach (s, this.entries) {
      msg (s)
    }
  }

mrangel
18 Jul 2018, 17:30

That looks correct to me.

Are you sure it's in that verb that the error appears?

NOTE: In the online editor, if you make a typo it will often save without saying anything is wrong. Then when you click on a different object to edit, an error message will pop up. And it'll keep on showing that error message until you refresh the browser, even if the problem is fixed. That's a bug in the online editor.

  1. So, first question: Does the error still appear if you refresh the browser, or if you leave the site and come back?

  2. The code you posted there looks fine. So the editor is probably showing the error in the wrong place. It does that sometimes.
    Here's how I go about solving those problems:

    1. Go to the "My Games" page
    2. Click "Download" for the game with the problem
    3. Open the file in Notepad or vim. If you're not used to dealing with file extensions, the easiest way is to drag the file into a Notepad window.
    4. Use the search/find feature to look for the text from the error message (ListCount(this). It might be in a few different places. Look at all of them, and see if you can see which one has a ( or ) missing.
    5. If you can't find the problem, you could copy the whole file from Notepad, and show it to us here.

Hope that helps.


DonJohn
19 Jul 2018, 07:02

So, atleast I do not have to feel that stupid...lol

I did what you said there. I restarted the browser after i putted everything in and you know what. The messages was gone after that.... However...

When I started the game and typed "read journal" i get this:

read journal
Error running script: Error compiling expression '.entries': SyntaxError: Unexpected token "."; expected one of "NOT", "-",

Right now I am on an iPad so it is impossible to download the game.
I have tryied to look line by line in all the codes and cannot see any issues.
I even started a game from scratch and tryied to make the journal but i get the same issues.

Is it anyone of you that knows an app that can open the aslx file or an online reader... or how to call it?


mrangel
19 Jul 2018, 07:16

If you publish the game then somebody else will be able to take a look at it.

That error message is a strange one. It says it's finding .entries where it wasn't expecting it. So it's trying to treat this and .entries as separate words. Is there a space or any punctuation between them?


DonJohn
19 Jul 2018, 08:22

Ok so get this....

I published a completly clean vanilla game. The only thing i added was the journal and guess what? When it is published it works....

But as a test game it does not.

How can this be?

I am so confused now lol


DonJohn
19 Jul 2018, 09:04

Well I must have done something by lucky misstake becouse when I tryied with the other one it did not work... I will become crazy over this lol


DonJohn
19 Jul 2018, 09:48

Let us say that one would create the journal "manually" with the buildt in scripts that are in quest. How wouuld one do that?


hegemonkhan
19 Jul 2018, 11:44

I published a completly clean vanilla game. The only thing i added was the journal and guess what? When it is published it works.... (DonJohn)

I think as mrangel was saying, when you delete something via the GUI/Editor, it doesn't go and find and remove all of the scripting/code involved, and so that's why you get the error (unless you manually go through your code and remove/fix the related code that wasn't removed/fixed)

and thus when you started over, doing everything correctly (no deleting of actions/code through the GUI/Editor), it works fine now


Let us say that one would create the journal "manually" with the buildt in scripts that are in quest. How wouuld one do that? (DonJohn)

creating an advanced functional 'journal' (records system) is not easy to do...

but just the basics of it:

a 'journal' is merely using a Dictionary Attribute (and you may also want to use List Attributes too):

http://docs.textadventures.co.uk/quest/using_lists.html
http://docs.textadventures.co.uk/quest/using_dictionaries.html

basically, what lists/dictionaries are, are input-output functionalities:

String List:

input: "key" String Value: index number: (first item starts at/is: '0', NOT as: '1')
output: "value" String Value: (custom: whatever you want)

Object List:

input: "key" String Value: index number: (first item starts at/is: '0', NOT as: '1')
output: "value" Object Value: (custom: whatever you want)

String Dictionary:

input: "key" String Value: (custom: whatever you want)
output: "value" String Value: (custom: whatever you want)

Object Dictionary:

input: "key" String Value: (custom: whatever you want)
output: "value" Object Value: (custom: whatever you want)

Script Dictionary:

input: "key" String Value: (custom: whatever you want)
output: "value" Script Value: (custom: whatever you want)


here's a detailed guide on using lists and dictionaries:

http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk


// so, for a simple example of creating a 'journal':

'Page1' -> 'Page' Tab -> Page Type: [script] or [text + script] -> (see below)

add new script -> 'output' section/category -> 'set a variable or attribute' Script -> (see below, an example)

set variable game.journal = [EXPRESSION] NewStringDictionary ()

// ------------------------------------

// adding a journal entry:

(whatever page) -> 'Page' Tab -> Page Type: [script] or [text + script] -> (see below)

// after asking the king about the 'princess' topic (not showing the scripting of that here though):

add new script -> (whatever section/category) -> 'dictionary add' (or whatever it is called) Script -> (see below, an example)

// dictionary add (DICTIONARY, INPUT, OUTPUT)

dictionary add (game.journal, "princess", "The princess has been kidnapped by a dragon, please rescue here!")

// --------------------

// removing/changing a journal entry:

(whatever page) -> 'Page' Tab -> Page Type: [script] or [text + script] -> (see below)

// after/upon rescuing the 'princess':

add new script -> (whatever section/category) -> 'dictionary remove' (or whatever it is called) Script -> (see below, an example)

// dictionary remove (DICTIONARY, INPUT)

dictionary remove (game.journal, "princess")

add new script -> (whatever section/category) -> 'dictionary add' (or whatever it is called) Script -> (see below, an example)

// dictionary add (DICTIONARY, INPUT, OUTPUT)

dictionary add (game.journal, "princess", "The princess has been kidnapped by a dragon, please rescue here! (COMPLETED)")

// -------------------

// viewing your journal entries:

(whatever page) -> 'Page' Tab -> Page Type: [script] or [text + script] -> (see below)

// scripting to view whatever journal entry/item you want (not showing the scripting of that here though)

jmnevil54
19 Jul 2018, 22:39

I believe these people were talking about string lists. If you do not have a list already, then make one. On the web version you just click on one of the scripts, and it should be the same for the offline version.

Other than that, pay attention to what everyone else said.


DonJohn
20 Jul 2018, 11:16

wow, it is alot to take in lol
But I am very greatful for al you help and inputs,
I am learning more and more here and alot by this.

I Will keep mess around with it to see if I can find what causes this

Thank you!