Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Images being triggered into a miniwindow

Images being triggered into a miniwindow

You need to log onto the forum to reply or create new threads.

  Refresh page


Posted by Winddancer   (29 posts)  Bio
Date Mon 07 Apr 2025 07:59 AM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 08 Apr 2025 08:43 PM (UTC)
Message
That is certainly achievable. I have some pages about miniwindows including creating them and displaying images:

https://gammon.com.au/mw

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Winddancer   (29 posts)  Bio
Date Reply #2 on Thu 10 Apr 2025 10:08 AM (UTC)

Amended on Sat 12 Apr 2025 06:29 PM (UTC) by Winddancer

Message
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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 10 Apr 2025 09:33 PM (UTC)
Message

<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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Winddancer   (29 posts)  Bio
Date Reply #4 on Fri 11 Apr 2025 04:40 AM (UTC)
Message
Many many thanks.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


602 views.

You need to log onto the forum to reply or create new threads.

  Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.