using thumbnails in a menu instead of text

I am playing with setting up a menu that displays thumbnail images instead of text,
but I don't think I am formatting the the code correctly, if it is even possible.
This is just part of the code, the compiler keeps truncating the code and I have to keep retyping it.

menuPic1 = "chr(60) + " a href =  'https://i.imgur.com/vmFz0gn.jpg' + chr(62)" // here I would add the img src as per html to load the thumbnail with a width of say 50px

list add (menuList, menuPic1)

Are you using this for show menu or ShowMenu, or is it just a menu in a stylistic sense?
Quest's menu functions will already be wrapping an <a> tag around the text you pass to it, and having nested <a>s is invalid HTML. Also, there should not be a space between the < and the element name.

The more direct problem is that your quotes don't match up.
You have a " right after the equals sign, so the Quest interpreter knows that chr(60) + is literal text that you want to send to the player, rather than a function to run. Then, after the closing quote, it sees an a on its own. So you want to use the a operator to combine the string "chr(60) + " with whatever comes next. And it fails here, because a isn't an operator in Quest's expression language.

If you want your string to contain the HTML: <a href="https://i.imgur.com/vmFz0gn.jpg" >
then your code should be:
menuPic1 = Chr(60) + "a href=\"https://i.imgur.com/vmFz0gn.jpg\" " + Chr(62)
(presumably with the rest of the HTML after it)


K.V.

Maybe:

menuPic1 = Chr (60) + "a href = \"https://i.imgur.com/vmFz0gn.jpg\"" + Chr (62)

That's the Quest equivalent of this in HTML: <a href="https://i.imgur.com/vmFz0gn.jpg">


EDIT

Ha ha!

mrangel provided a more thorough answer, and he must have clicked "Post Reply" as soon as I started typing my answer.

We do that a lot. Great minds and all...


Tried it again, the menu shows the raw HTML, it is not being processed as HTML, just as straight text.

menuList = NewStringList()
menuPic1 = Chr(60) +"a href = \" https://i.imgur.com/vmFz0gn.jpg\"" + Chr(62)  //this is the text in the menu
list add (menuList, menuPic1)
list add (menuList, "showing")
list add (menuList, "menus")
show menu ("Welcome to Chapel Perilous", videos.videoList, true) {
  ShowYouTube (result)  //works fine
  wait {
    show menu ("Test menu after videos", menuList, true) {  //the menu is rendered, but with raw HTML as the text
      if (result = menuPic1) { //nothing happens here
        msg ("menuPic1")  
      }
      else if (result = "showing") {
        msg ("showing")
      }
      else if (result = "menus") {
        msg ("menus")
      }
      else {
        msg ("How did that happen")
      }
    }
  }
}

Not sure how to approach that, I'm afraid. I know it should work with ShowMenu, but I can't find the source for show menu to see where the problem is.


tried ShowMenu for the nested menu, with and without the a href bit

menuList = NewStringList()
menuPic1 = chr(60) +" img src = 'https://i.imgur.com/vmFz0gn.jpg' /" + chr(62)
list add (menuList, menuPic1)
list add (menuList, "showing")
list add (menuList, "menus")
show menu ("Welcome to Chapel Perilous", videos.videoList, true) {
  ShowYouTube (result)
  wait {
    ShowMenu ("Test menu after videos", menuList, true) {
      if (result = menuPic1) {
        msg (chr(60) + "img src = https://i.imgur.com/vmFz0gn.jpg /" + chr(62))
      }
      else if (result = "showing") {
        msg ("showing")
      }
      else if (result = "menus") {
        msg ("menus")
      }
      else {
        msg ("How did that happen")
      }
    }
  }
}

with <a href = ... code, the menu creates a link that takes me to another website. Not what I am looking for.
Without <a href = ... code

Test menu after videos
1: < img src = 'https://i.imgur.com/vmFz0gn.jpg' />
2: showing
3: menus

simplified the code to see what would happen

menuList = NewStringList()
menuPic1 = "squatterman"
list add (menuList, menuPic1)
list add (menuList, "showing")
list add (menuList, "menus")
show menu ("Welcome to Chapel Perilous", videos.videoList, true) {
  ShowYouTube (result)
  wait {
    ShowMenu ("Test menu after videos", menuList, true) {
      if (result = menuPic1) {
        msg (chr(60) + "img src = https://i.imgur.com/vmFz0gn.jpg /" + chr(62))
      }
      else if (result = "showing") {
        msg ("showing")
      }
      else if (result = "menus") {
        msg ("menus")
      }
      else {
        msg ("How did that happen")
      }
    }
  }
}

Error running script: Error compiling expression 'result = menuPic1': Unknown object or variable 'menuPic1'


K.V.

Local variables aren't accessible from within that ShowMenu block of code (or from within that wait block of code).

Try making menuList and menuPic1 game attributes (global variables) instead of local variables, this:

game.menuList = NewStringList()
game.menuPic1 = "squatterman"
list add (game.menuList, game.menuPic1)
list add (game.menuList, "showing")
list add (game.menuList, "menus")
show menu ("Welcome to Chapel Perilous", videos.videoList, true) {
  ShowYouTube (result)
  wait {
    ShowMenu ("Test menu after videos", game.menuList, true) {
      if (result = game.menuPic1) {
        msg (Chr(60) + "img src=\"https://i.imgur.com/vmFz0gn.jpg\" /" + Chr(62))
      }
      else if (result = "showing") {
        msg ("showing")
      }
      else if (result = "menus") {
        msg ("menus")
      }
      else {
        msg ("How did that happen")
      }
    }
  }
}

Reference:
http://docs.textadventures.co.uk/quest/blocks_and_scripts.html


I also changed your chr() to Chr() in both instances.

Reference:
http://docs.textadventures.co.uk/quest/functions/string/chr.html


I also removed the spacing and added the quotation marks around the url in the image tag.


K.V.

PS

mrangel, here is the show menu Quest script (if this helps anything).

https://github.com/textadventures/quest/blob/beaeade160c4c1a2912b9d0b52f9ac7a5c4b78f8/WorldModel/WorldModel/Scripts/ShowMenuScript.cs


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

Support

Forums