Images being triggered into a miniwindow

Posted by Winddancer on Mon 07 Apr 2025 07:59 AM — 5 posts, 7,275 views.

#0
I would like to achieve the following, as I am a person that best reacts to optical stimulus and my short term memory is kinda suffering recently:
A mud message is caught with a trigger. That trigger displays a text message on screen (not necessary) and also displays an image in the miniwindow (main goal).
Another mud message is caught with a trigger. that trigger displays a different message on screen (again, not necessary) and either moves the image in the mini window or displays a different image in the mini window (main goal).


E.g.
MUD: The <weapon name> gets stuck in the militant orc's stuff.
Text Trigger: WEAPON GOT STUCK.
Image trigger: display image1 in mini window.

MUD: You get <weapon name> from the corpse.
Text trigger: WEAPON RECLAIMED
Imagte trigger: remove image 1 in mini window or display image 2 in mini window.
Australia Forum Administrator #1
That is certainly achievable. I have some pages about miniwindows including creating them and displaying images:

https://gammon.com.au/mw
#2
Thanks for the pointers Nick, they helped me a lot.

I wrote a little plugin to handle the displaying. I have the miniwindow shown and I can move it around. The image display doesn't seem to work though.
The individual commands work, at least when I tested them in the Immediate window.
Within the plugin I defined the following triggers.

<triggers>
  <trigger
   enabled="y"
   match="*gets stuck in*"
   send_to="12"
   sequence="100"
  >
  <send>showStuck</send>
  </trigger>
  <trigger
   enabled="y"
   match="^You * in *: Unstuck"
   send_to="12"
   sequence="100"
  >
  <send>showClear</send>
  </trigger>
  <trigger
   enabled="y"
   match="^You * in *: Stuck"
   send_to="12"
   sequence="100"
  >
  <send>showStuck</send>
  </trigger>
</triggers> 

The called functions are:

function showStuck()
	local f = assert (io.open ("D:\Program Files (x86)\MUSHclient\images\black.png", "rb"))  -- open read-only, binary mode
	local image_data = f:read ("*a")  -- read all of it
	f:close ()  -- close it
	WindowLoadImageMemory (win, "im1", image_data) -- load image from memory
	WindowDrawImage (win, "im2", 5, 5, 115, 115, miniwin.image_stretch)  -- draw it
end

function showClear()
	local f = assert (io.open ("D:\Program Files (x86)\MUSHclient\images\weapon.png", "rb"))  -- open read-only, binary mode
	local image_data = f:read ("*a")  -- read all of it
	f:close ()  -- close it
	WindowLoadImageMemory (win, "im2", image_data) -- load image from memory
	WindowDrawImage (win, "im1", 5, 5, 115, 115, miniwin.image_stretch)  -- draw it
end

The second and third trigger are meant to be used for testing, so that I can say stuff , the plugin trigger catches the said and then triggers the appropiate functions.

The images, im1 and im2 are loaded within the function PluginInstall, where the function ImageLoad is called.

function ImageLoad()
	local f = assert (io.open ("D:\Program Files (x86)\MUSHclient\images\black.png", "rb"))  -- open read-only, binary mode
	local image_data = f:read ("*a")  -- read all of it
	f:close ()  -- close it
	WindowLoadImageMemory (win, "im1", image_data) -- load image from memory

	local f = assert (io.open ("D:\Program Files (x86)\MUSHclient\images\weapon.png", "rb"))  -- open read-only, binary mode
	local image_data = f:read ("*a")  -- read all of it
	f:close ()  -- close it
	WindowLoadImageMemory (win, "im2", image_data) -- load image from memory
end -- end ImageLoad


When the first trigger is called, the client returns:

Compile error
Plugin: Yoriks_Graphical_Reminder (called from world: Geas)
Immediate execution
[string "Trigger: "]:1: '=' expected near '<eof>'


Please help
Amended on Sat 12 Apr 2025 06:29 PM by Winddancer
Australia Forum Administrator #3

<triggers>
  <trigger
   enabled="y"
   match="*gets stuck in*"
   send_to="12"
   sequence="100"
  >
  <send>showStuck</send>


To call showStuck you have to put brackets after it, eg.


showStuck()


Alternatively, put "showStuck" into the "script" box in the trigger, and leave the trigger send box empty.

It would be faster to load both images in the plugin install, not make them local variables, then just do WindowDrawImage when you want to draw the images.
#4
Many many thanks.