Image preview in client

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
Proxy
Posts: 27
Joined: Sun May 08, 2016 4:57 pm

Image preview in client

Post by Proxy » Tue May 30, 2017 6:09 am

Hi guys. I know you're all busy and such, but I came across a feature on the MOO I play that I would very much like to see implemented while I play it on Mudlet. I have no idea how to go about making a script for it, but someone said that it would be possible.

The feature is just an image preview within the client. In other words, once someone types an image url, you can click on the link and see a preview within the client. I attached an example. The first pic shows what happens when you click on link. At the bottom of the screen the same link was resent but without clicking on it. All you see is the link in blue and an arrow pointing up next to it.

This is the image.

Does anyone have such a script of their own I could use perhaps?

Moderator Edit: I think this is the image they were trying to show:
qxqORTS.png
Last edited by Proxy on Tue May 30, 2017 2:42 pm, edited 1 time in total.

Jor'Mox
Posts: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: Image preview in client

Post by Jor'Mox » Tue May 30, 2017 12:55 pm

Unfortunately, the image you included isn't working, so it is a bit hard to visualize.

But, you should be able to use a trigger to recognize an image URL, and convert that into a clickable link (and probably also download the image in the background to make it respond quicker once you click it), and then when the link is clicked, make a label visible and have it display the downloaded image.

I'm thinking the trigger would need code something like this:
Code: [show] | [select all] lua
local link = matches[2]
local file = string.match(link,[[/([\w_]+\.(?:gif|jpg|png))$]]) -- note that you will need to add file extensions to match whatever you want to be able to display (I'm being lazy here and only putting in a couple), or you could make it generic, and just let your trigger deal with excluding non-image files.
downloadFile(getMudletHomeDir() .. "/Preview Images/" .. file, link)
selectString(link,1)
setLink([[showImagePreview(]] .. file .. [[)]],"Show Image Preview")
And then you would need to make the showImagePreview function in a script, and it would need to be something sort of like this (I'm assuming here that you are already creating, sizing, and positioning a label for this purpose, but obviously adjust as needed):
Code: [show] | [select all] lua
function showImagePreview(file)
   local path = getMudletHomeDir() .. "/Preview Images/" .. file
   setBackgroundImage("myImagePreviewLabel",path)
   showWindow("myImagePreviewLabel")
end

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests