Hints & Achievements

Never mind – solved it after asking for help (as usual).

To add insult to injury, using Workbench to try to step through the library code and figure out what methods are calling the Goal object – that being the object containing the hints – does not work.

I set a breakpoint in my own setPoints() method. When the breakpoint is reached, I use F11 to step through. What I see is a little loop in which setPoints() is called three or four times in quick succession, alternating with the openWhenSeen property of the Goal – and there is NOTHING in between the two. This would appear to be impossible. The library has to be doing something, because it’s in the process of iterating through my list of hints! After which, something in the library takes a look at openWhenSeen. But whatever code is doing that is not accessed by F11 (Step Into).

Later on in the process, F11 walks me through dozens of obscure parts of the library. And then it returns to my Goal and my setPoints() and iterates through that loop a few more times, again with nothing else intervening to show what library code is iterating through the list of hints.

I’m baffled.

It appears from the documentation that one can create a Hint object and use it as an entry in the event list for a Goal, in place of simple single-quoted text. Specifically, the Library Reference Manual says this about the Hint class: “a Hint object can specify some additional code to run when the hint is shown, so that it can apply any side effects of showing the hint.”

Sounds like exactly what I need, doesn’t it? Tried it. Doesn’t work properly. The Hint class has a method called getItemText, which is supposed to return the value (string) of the hintText property. So I did this:

+++ boxHint6: Hint hintText = '\bIf you’re not computer-literate, you may want to look up hexadecimal numerals online. ' getItemText() { restorePowerAch.setPoints(6); inherited(); } ;
Notice the careful use of inherited()? That should cause getItemText() to return the string in hintText. But when I use the Watch Expressions on that method in the library code, once getItemText() returns, hintText is suddenly nil.

That is to say, my call to setPoints(x) is now working fine – but the Hint object is refusing to print any damn text. However, if I comment out my version of getItemText() – the one shown above – the hintText DOES print.

It appears that inherited() doesn’t work in this particular method. Why would that be? I’m baffled again.

But in the end, it doesn’t matter that I’m baffled. I can reproduce the entire block of code in getItemText() by hand in my own code, add my own code, and the hint DOES print. This solves the problem.

It’s a bug in the library, that’s all. I’ll notify people.

Shouldn’t it be “return inherited();” then? Btw. great you are doing some IF again :slight_smile:

Yes, that was the mistake I made. I haven’t done any coding at all for a couple of years, so I’m stumbling around trying to get back into it.

I had an email a few weeks ago from someone who had played a couple of my games and is a fan of old-school puzzle-oriented games. That’s all it takes to get me going – one fan letter. Anyway, puzzle-oriented games are the only kind that I would want to do. I’ve done most of the design work on this new game, but it’s less than half written.

Every day I tackle a new conundrum. Today I’m trying to get the BagOfHolding to work properly. It works on the basis of bulk, but not on the number of items held. If the player has a bulkCapacity of 100 and is carrying 15 items, each with a bulk of 6 or less, the BagOfHolding is never called upon to do anything and the scenario (the PC wandering around carrying four keys, three gold coins, four short electrical cables, a feathered dart, and a pill bottle) is ridiculous. I’m going to try to hack it so that the number of items is also taken into consideration.