GMCP image display

Post Reply
tomteng
Posts: 2
Joined: Fri Oct 26, 2018 2:14 pm

GMCP image display

Post by tomteng » Fri Oct 26, 2018 3:49 pm

Hi there, my friends and I are trying to build a mud game with light image content.
I'm currently looking at the Geyser GUI tutorial, and I just want to ask if it is possible to display an online image in the mudlet client? like a small icon saved on online server.
When I tried to implement it with the method in tutorials, I only got a grey square with size I set.
Thanks for any help!

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

Re: GMCP image display

Post by Jor'Mox » Sat Oct 27, 2018 12:05 am

You likely just got a gray square because the file path for the image either wasn't right, or had \ as the directory separator, instead of / (which happens on Windows, but not other OSs, when you use getMudletHomeDir()). To make the image display correctly, you want to replace the backslashes with forward slashes, and it will likely work.

As far as loading images from the internet, I'm not certain if they can be loaded from a remote site, but you can certainly download them from a remote site, and then display them from a local source. If you are reusing images a lot, that will probably work out well enough.

tomteng
Posts: 2
Joined: Fri Oct 26, 2018 2:14 pm

Re: GMCP image display

Post by tomteng » Sat Oct 27, 2018 3:35 pm

Jor'Mox wrote:
Sat Oct 27, 2018 12:05 am
You likely just got a gray square because the file path for the image either wasn't right, or had \ as the directory separator, instead of / (which happens on Windows, but not other OSs, when you use getMudletHomeDir()). To make the image display correctly, you want to replace the backslashes with forward slashes, and it will likely work.

As far as loading images from the internet, I'm not certain if they can be loaded from a remote site, but you can certainly download them from a remote site, and then display them from a local source. If you are reusing images a lot, that will probably work out well enough.
Thanks! I just figure out how to display it. Previously I tried to display the pic right after downloading, but actually the image was not downloaded yet. I solved it by using sysDownloadDone event. For those who may have the same problem:

Code: Select all

function display_image(_, filename)
-- some code here
end

-- register our function to run on the event that something was downloaded
registerAnonymousEventHandler("sysDownloadDone", "display_image")

-- download a list of fake users for a demo
downloadFile("dir","url")

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

Re: GMCP image display

Post by Jor'Mox » Sat Oct 27, 2018 3:48 pm

Yup, just make sure you check to see if the file needs to be downloaded, or if it is already available locally, and you should be good.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests