In-game HINTS menu

COMMAND

Command pattern:
hint;hints

if (not HasAttribute(Hinting, "warnedonce")) {
  Hinting.warnedonce = false
}
if (not Hinting.warnedonce) {
  Ask ("You have asked to see the hints.<br>Is this correct?") {
    if (result = true) {
      Hinting.warnedonce = true
      HandleSingleCommand ("hint")
    }
    else {
      msg ("I'm so proud of you!")
    }
  }
}
if (Hinting.warnedonce) {
  if (game.hintson) {
    hintsavailable = false
    hintable = NewObjectList()
    foreach (o, AllObjects()) {
      if (HasAttribute(o, "hints")) {
        list add (hintable, o)
        hintsavailable = true
      }
    }
    if (hintsavailable) {
      ShowMenu ("What would you like a hint about?", hintable, true) {
        do (GetObject(result), "hints")
      }
    }
    else {
      msg ("There are no hints available. (Sorry!)")
      DisplayHttpLink ("Contact Richard Headkid at textadventures.co.uk", "http://textadventures.co.uk/user/view/GudEjTsX9kOMAgJ-TFFyFg/richard-headkid", false)
      msg ("")
    }
  }
}

the laser sword (object - complete with Hints script dictionary)

<object name="laser sword">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <feature_switchable />
      <take />
      <feature_usegive />
      <inventoryverbs type="stringlist">
        <value>Look at</value>
        <value>Drop</value>
        <value>Switch on</value>
        <value>Switch off</value>
      </inventoryverbs>
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Take</value>
        <value>Switch on</value>
        <value>Switch off</value>
      </displayverbs>
      <onswitchon type="script"><![CDATA[
        msg ("<h1>ZWOOMPH!!!</h1>")
      ]]></onswitchon>
      <onswitchoff type="script"><![CDATA[
        msg ("<h6>ssssfwhoomp.</h6>")
      ]]></onswitchoff>
      <hints type="script">
        ShowMenu ("What do I do with the laser sword?", laser sword.hinttopics, true) {
          invoke (ScriptDictionaryItem (laser sword.hinttopics,result))
        }
      </hints>
      <about type="script">
        do (laser sword, "hints")
      </about>
      <hinttopics type="scriptdictionary">
        <item key="Hint 1"><![CDATA[
          msg ("HINT 1<br/>You can turn the laser sword on and off. (It will provide a light in dark places.)<br/>")
          do (laser sword, "hints")
        ]]></item>
        <item key="Hint 2"><![CDATA[
          msg ("HINT 2<br/>You could also give the sword to Ralph.<br/>")
          do (laser sword, "hints")
        ]]></item>
        <item key="Hint 3"><![CDATA[
          msg ("HINT 3<br/>Ralph will go buck wild on a bad guy with the laser sword if you ask him to.<br/>")
        ]]></item>
      </hinttopics>
    </object>

http://textadventures.co.uk/games/view/i8xpc6jwue6xjtwq2tr03w/laser-sword-with-hints-example


awesome, thank you for posting this, will be of great help to a lot of people, we need a lot more public guides/libraries/codes for people to be able to use! As quest is such a good engine/software/program... but we've not made as many publically available guides/libraries/codes as we should have over the years.


No problem!
Just trying to do my part to help out!


I added a HINTS tab to the editor last night, but all the code magically disappeared every time I switched to Code View and back, even though I saved.

I'm pretty sure I need to have all of that code in a library to avoid that, and the goal is to convert this to a library anyway, so it should all work out (I hope). (I may even figure out how to add the HINTS option in the Features tab...)


This is RH, by the way.
(I made a new account.)


... New guy, same as the old guy...
(now, name that song that resembles...)


Tabs need to go in a library file. Quest just deletes them. As you found.


the common mistake is people referencing/using the: 'editor_xxx' Inherited Attributes thinking they can just use them for identification/flagging... not realizing they get destroyed at game start (as they're just for doing all the GUI/Editor controls/options/boxes/etc for you to use in the GUI/Editor):

if (DoesInherit (this, "editor_room")) {
  list add (game.room_list, this.name)
}

ERROR! The 'editor_room' Inherited Attribute doesn't exist!


not too many people learn how to use the GUI/Editor 'tab' creation coding (Pixie's old "about tabs" and "about tabs and types", and "more about types" which covered the GUI/Editor tabs and Pixie's monster and spell coding in the tutorial, lol. But this was quite awhile ago)

I did learn how to do this coding, but haven't ever used it (as I've just been trying to create my own game directly in code as I don't kow the GUI/Editor that well and prefer to just code directly as I know how to now), so I've forgotten, would ahve to re-read/learn it again, lol.
(it's not too difficult, or at least it's not because Pixie is good at explaining/guiding through understanding and using it)
(just have to find where Pixie's info/guide is at within the restructuring of the doc page and/or check pixie's github page, where-ever it's at now, lol)


@DL
Will you not be fooled (again)?

@Px
I think it deletes them as soon as I use that new tab.

I looked at the group project library file to get as far as I have with the tab. Quest only deleted it 4 or 5 times before I realized that was probably the reason you had that stuff in the library rather than the main game file.

This currently consists of a command, a function, a script and a script dictionary, but I'm fairly certain I can lose the script.


@ anyone

How do I pass these variables into ShowMenu? (I don't want to create an attribute on anything if I don't have to. (Can I destroy an attribute?)

(In this example, I had to enter them a second time...)

Also, is there some equivalent to this in the editor? (Meaning: I'm in the object's tab in the editor. Does the editor now recognize the object as object?)

key = "Hint 1"
obj = empty_hint_object
msg (key)
ShowMenu ("Hints for " + GetDisplayName(obj) + "", obj.hinttopics, true) {
  key = "Hint 1"
  obj = empty_hint_object
  msg (key)
  invoke (ScriptDictionaryItem (obj.hinttopics, key))
}

I thought I'd at least perused everything on Pixie's wiki*, but HK mentioned a Tabs document*, so I went back and found this (for anyone who may be interested)....

https://github.com/ThePix/quest/wiki/Using-Tabs-and-Types


Working on this for the online editor

keys = NewStringList ()
foreach (key, game.hints) {
list add (keys, key)
}
ShowMenu ("What would you like a hint about?", keys, true) {
msg (StringDictionaryItem (game.hints, result))
}


Here's a simplified script attribute for the horse, which displays one hint at a time, with a link to view the next hint:

<hints type="script"><![CDATA[
      ShowMenu ("What am I supposed to do with the horse?", Split ("Hint 1", ";"), true) {
        msg ("HINT 1<br/>You can get the horse to stop following you by entering: HORSE, STAY.<br/><br/>")
        ShowMenu ("", Split ("HINT 2", ";"), false) {
          msg ("HINT 2 <br/>Enter: HORSE, FOLLOW ME to get the horse to follow you again.")
          ShowMenu ("", Split ("HINT 3", ";"), false) {
            msg ("HINT 3<br/>You can WHISTLE while the horse is not in the location (as long as you're outside), and the horse will make its way to you.<br/><br/>")
            ShowMenu ("", Split ("HINT4", ";"), false) {
              msg ("HINT 4 <br/>You can also ride the horse.<br/><br/>Use the commands: MOUNT or DISMOUNT.<br/><br/>")
            }
          }
        }
      }
    ]]></hints>

Actually.. I was thinking of Henry the Eight...
"Next verse, same as the last..."


I am Henry the Eighth, I am
Henry the Eighth, I am, I am!


@DL

What'chu talkin' 'bout, Willis?


Who can forget Different Strokes???


Actually.. I was thinking of Henry the Eight...
"Next verse, same as the last..."

Oh! I see!

... I thought you were making a 'recursive' joke! (slaps forehead) Doh!

You were talkin' 'bout:

... New guy, same as the old guy...
(now, name that song that resembles...)

I immediately thought of The Who, and I took 'new guy, same as the old guy' as a substitute for 'new boss, same as the old boss', which would have been quite fitting... because I'm just this guy, you know. (I've turned down managerial positions more than once. I'm too empathetic to be in charge of anything!)


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

Support

Forums