Page 1 of 1

GMCP image display

Posted: Fri Oct 26, 2018 3:49 pm
by tomteng
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!

Re: GMCP image display

Posted: Sat Oct 27, 2018 12:05 am
by Jor'Mox
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.

Re: GMCP image display

Posted: Sat Oct 27, 2018 3:35 pm
by tomteng
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")

Re: GMCP image display

Posted: Sat Oct 27, 2018 3:48 pm
by Jor'Mox
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.