String dictionary issue

xordevoreaux
I'm getting "function not found" on the line below:
msg (StringDictionaryItem(this.Bookpage, this.CurrentPage))

Error running script: Error compiling expression 'StringDictionaryItem(this.Bookpage, this.CurrentPage)': FunctionCallElement: Could find not function 'StringDictionaryItem(QuestDictionary`1, Int32)'

but I copied and pasted "StringDictionaryItem" right from the Quest online help, so it's not a typo.
Can't figure it out. Basically my book is a string dictionary, and the player can flip pages to set CurrentPage.


<type name="wt_objmod_book">
<IsBook type="boolean">false</IsBook>
<Bookpage type="stringdictionary">
<item>
<key>1</key>
<value>page one</value>
</item>
<item>
<key>2</key>
<value>page two</value>
</item>
<item>
<key>3</key>
<value>page three</value>
</item>
</Bookpage>
<CurrentPage type="int">2</CurrentPage>
<ReadBook type="script">
msg ("Readbook script goes here.")
msg (StringDictionaryItem(this.Bookpage, this.CurrentPage))
</ReadBook>
<read type="script"><![CDATA[
// The World Template uses a script rather than the game engine's default verb attribute "read" which had a string attribute.
// To support the default "read" command, click Make Editable Copy and change the text string at the very bottom of this script. Do NOT modify wt_obj or wt_objmod_book.
if (this.IsBook=True) {
do (this, "ReadBook")
}
else {
// Click the Make Editable Copy button to change this:
msg ("--Modify the Read Verb for this <i>particular</i> object and change the script for text to appear here--")
}
]]></read>
</type>

xordevoreaux
Fixed. I had to convert my CurrentPage integer to a string for the 2nd parameter.

StringDictionaryItem(this.Bookpage, ToString(this.CurrentPage))

HegemonKhan
good job understanding and finding the mistake, nice catch!

-----------

the Dictionary (String Dictionary, Object Dictionary, and Script Dictionary) Attributes are basically an 'input->output' Function'ality:

String Dictionary:

input: "string1" // this is why you had to convert your 'this.CurrentPage' Integer (int) Attribute's value of 'data type: integer (int)' to 'data type: string'

output: "string2"

"string1" = "string2" // (input) "string1" -> (output) "string2"
StringDictionaryItem (Object_name.String_Dictionary_Attribute_name, input "string1") -> returns (outputs): "string2"

Object Dictionary:

input: "string"
output: object

// the Object has to actually exist of course too (the Object itself is not actually inside of the Object List, think of the Object List as a PE class' student roster, a piece of paper with the students' names on it, but not the actual students are upon/inside the paper lol, but it can be used by the PE teacher to bark/issue orders to those students)

"string" = object // (input) "string" -> (output) object
ObjectDictionaryItem (Object_name.Object_Dictionary_Attribute_name, input "string") -> returns (outputs): object

Script Dictionary:

input: "string"
output: script

"string" = script // (input) "string" -> (output) script
StringDictionaryItem (Object_name.Script_Dictionary_Attribute_name, input "string") -> returns (outputs): script

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

if you can follow my posts (lol), here's some links on using lists/dictionaries, if you're interested in understanding them more:

viewtopic.php?f=18&t=5137 (my guide on using/understanding lists/dictionaries)
viewtopic.php?f=18&t=5138 (code/game sample of their implementations in action, the code might not work as a functioning game with the current version of quest, as it's old code and/or still have some mistakes in it, lol)

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

Support

Forums