Keeping track of potions/pills etc.

Posted by Eloge on Sun 24 Oct 2010 08:18 AM — 7 posts, 28,779 views.

#0
I have been thinking about creating a window that keeps an up-to-date track on stuff, namely potions,
which I, btw. call internally my 'life insurence'. Yes, they are so important in my play. I want to know - all the
time - how many I am left with at that moment.

Probably a mini-window would be the solution? Then, howto get the appropriate text into that mini-window. I get
from the mud 'You have bought a potion of...' and 'You quaff a potion'. I can also give the command 'look in bag' (where I store my potions. I can have up to 100 potions.

I have created a mini-window and have it placed where i want it to go on my screen. But now???

So, what should I do next. Thanks for any advice?

#1
Have a trigger that detects the number of potions in your bag, and sets that to a potion_count variable:

look in bag
You look in your bag.
You see:
a lantern
some potions[55]
lots of coins [35943]
a pair of dirty socks

Trigger on "some potions\[(\d)+\]" or something like that, regex, and set %1 to the variable.

Trigger on "you quaff a potion" to remove one from potion_count.

Trigger on "you buy..." to add one to potion_count.

I'd do it all in a plug-in. Then it's a matter of every time you change the potion_count variable, redrawing the number in the miniwindow.
#2
LezChap finished the answer to my question where my question starts:

Quote:
Then it's a matter of every time you change the potion_count variable, redrawing the number in the miniwindow.


Yes, of course. Perhaps I am asking too elementary questions. This is however quite clear.

What I am asking, is howto draw the number of potions
(with some text) in the miniwindow.

My question begins where the answer finished. How do you put the contents of a variable (and text) in a mini-window, not how to calculate what to put into the window?
USA #3
Eloge said:
My question begins where the answer finished. How do you put the contents of a variable (and text) in a mini-window, not how to calculate what to put into the window?

The variable must first be a string or a number (some languages, like Lua, will coerce a number into a string when it's needed as a string). Then you can use WindowText() to draw the text to some point on the screen.
Australia Forum Administrator #4
This video (and small script underneath) show drawing text into a miniwindow:

http://www.gammon.com.au/forum/?id=9626
#5
Thanks!

Now I am on my way, not stuck any more, as I was.

Though I will need a lot of experimenting with the command line (from the video):

WindowText (win, font, "%0", 5, 5, 0, 0, ColourNameToRGB ("yellow"))

Especially the "%0" seems cryptical. How can it be replaced?

Thanks!

USA #6
%0 is a wildcard from a trigger or alias line. In fact, %0 means "all of the matched text", whether there were any wildcards in the pattern or not. If you want to test it outside a trigger or alias, just use whatever text you want to display, instead of %0.