Speak To A Character.

Trying to follow the documentation, but I'm doing something wrong.

      <look>Cooter is slumped at the kitchen table. {once:"Hi  {player.external_alias}," he says.}</look>
      <alias>Cooter</alias>
      <speak type="script">
        topics = Split ("Can you unlock this drawer for me??; What time is dinner??")
        ShowMenu ("Talk to Cooter about", topics, true) {
          switch () {
            case ("Can you unlock this drawer for me??") {
              msg ("Sure, Bubba. Allus happy to help a friend.")
            }
            case ("What time is dinner??") {
              msg ("About six o' clock.")
            }
          }
        }
      </speak>

The menu of questions to ask Cooter prints OK on the screen, in blue type. But when I click on one selection or the other, I get:

Error running script: Error compiling expression '': SyntaxError: Unexpected end of fileLine: 1, Column: 1

I have a hunch I've almost got it. There is some small syntax error. (I think.)


switch (result) {

Within a ShowMenu block, the value of the option that the player clicked on is stored in the variable result. The switch command needs to know which variable it should compare to the strings in the cases.

I also notice that you have a space after the ; in your Split. That means that when the second option is chosen, result will be: What time is dinner?? with a space at the beginning, so it won't match "What time is dinner??" in the case. You should remove the extra space.


Thanks. Got the code working. Can talk to Cooter, get his answer, and get him to unlock the drawer.

But then, when he answers or unlocks the drawer, the cursor won't go back to the rectangular box that says "Type here." I have to click on the box in order to type anything. Is it supposed to behave that way??

Another topic: Downloaded Quest "Conservation Library"
from GitHub. Don't know what to do with it. Do I just keep it handy and
copy blocks of code to the game as needed?? Or is there some way to
make it part of the game?? Maybe copy entire file to Code View??


Still hoping somebody will explain how to get the cursor to return to the rectangular player input box when the player finishes talking to a character.

But now I have a different issue. "The Shack" has received praise. People think it's one of the best Quest games ever. But I can't play it. When I load it, I get the picture of the building and the words "Title Screen" at upper left of window, and nothing else. Window is frozen. I cannot advance past the picture. If I click on "Restart," the window goes all white, and it's still frozen. Can't close Quest. Clicking on the X at upper right does nothing. Have to close Quest with Task Manager.

A file called "debug.log" appeared in the same directory as The Shack. Think maybe it has some bearing on the problem. (Though I'm not certain about that.) There's only one line in the file:

[0823/191400:ERROR:renderer_main.cc(207)] Running without renderer sandbox

Any ideas??


As for your cursor issue, try this:

JS.eval ("$('#txtCommand').focus();")

Hello.

This might help with the cursor in the input box thing:

      <speak type="script">
        topics = Split ("Can you unlock this drawer for me??; What time is dinner??")
        ShowMenu ("Talk to Cooter about", topics, true) {
          switch (result) {
            case ("Can you unlock this drawer for me??") {
              msg ("Sure, Bubba. Allus happy to help a friend.")
            }
            case ("What time is dinner??") {
              msg ("About six o' clock.")
            }
          }
          //The following line should place the cursor in the input box.
          JS.eval("$('txtCommand').focus();")
        }
      </speak>

EDIT

Ha ha!

Dcoder beat me to it! :o)


Concerning The Shack, you might get a response from someone who can help if you create a new forum thread for that issue.

I loaded the game online, and I just had to press ENTER twice to get past the opening screen in the web player. The desktop player definitely behaves differently. I'm not working in Windows today, though; so, I can't test it properly today.


Thanks, D Coder and K. V. I would have NEVER figured out that line, JS.eval("$('txtCommand').focus();") on my own.

Still have a lot to learn. Glad Quest documentation is extensive. But I'm ready to try writing a real game. We'll hope for the best.


Log in to post a reply.

Support

Forums