Axe Software Forums
  Quest Developer Forum
  Code to refresh panes


Author Topic:   Code to refresh panes
Mega posted 04-12-2001 21:12 GMT     
Until Alex codes an automatic solution to this into Quest, I thought I'd post the code I've been using to do it so far. It has never shown itself to fail.

This is a 3-part solution, but the code is very simple.

Step 1: In your 'afterturn' block (create one if you don't already have one) put the following:

if not ( #quest.originalcommand# = look ) then do <updatepanes>

Step 2: create the following procedure:

define procedure <updatepanes>
outputoff
set string <room; #quest.currentroom#>
goto <limbo>
goto <#room#>
outputon
end define

Step 3: create a room named 'limbo', which may or may not have stuff in it (it could be used as a holding area for items which will appear in the game later; just make sure the player can never get into the room on his/her own):

define room <limbo>
'any code you want
end define
---------------------------------------------
And there you have it. This code causes the panes to refresh after every turn. Use it well, grasshoppers. :-)

RKFM posted 04-12-2001 21:39 GMT          
Mega,

Very nice, thanks. At least your only have to do this once.

CW, have your tried this? I notice on the boards you've had some problems with this refresh thing.

Thanks again,

RK

Computer Whizz posted 04-12-2001 23:29 GMT          
---OR---

You could have it doing a:
for every object in #quest.currentroom#
hide #quest.thing#
show #quest.thing#

Which would slide through all of them refreshing the panel, and save you 10-25 lines of code (making the file smaller).

I think I'll wait and see if it's altered in Quest 3.01 - if not I'll do the above!

Computer Whizz

Mega posted 04-12-2001 23:40 GMT          
Actually, I don't think that would work. I tried a 'for every object in' block elsewhere, and this is what I found. Once an object is 'hidden', it is inaccessible not only to the player, but also to the game, UNLESS it is accessed specifically by name. So 'for every object in room' would not see it at all; only specifically 'showing' it by name would work.
Computer Whizz posted 05-12-2001 22:20 GMT          
No, you are quite right!

To do it you'd have to store all the names, then recall them. So you could use one variable, or an array - probably an array because you could: A) Make it up on the spot with a loop and a numeric, B) Use the array easier then finding the names from ONE string variable.

But yes, I was wrong in the first post.

Computer Whizz

Mega posted 06-12-2001 01:52 GMT          
And besides that, what about items you WANT to stay hidden? Your technique for refreshing the panes means that after each turn, every item in the room will be hidden, then revealed again. What if there's something that's already hidden, and you want it to stay that way?
Computer Whizz posted 06-12-2001 10:34 GMT          
But as you posted earlier it will miss the invisible object's and only do the visible ones!

Computer Whizz

Mega posted 06-12-2001 14:19 GMT          
Right. And you said that to get around that, you'd have to store the names of all objects in an array, then 'show' each of them by name. But if an item is already hidden and you want it to stay that way, you'd need a way to only 'show' objects that started out visible in the first place.

That's why I think my way of refreshing the panes is much cleaner and easier to implement; I don't need to worry about objects at all.

Computer Whizz posted 07-12-2001 07:58 GMT          
No - you use "for each object in <inventory>" to put the names into the array - then have the loop show all the names in the array. The hidden objects won't go into the array in the first place....

Computer Whizz