[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Retrieving and displaying a URL
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Retrieving and displaying a URL

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Larkin   (278 posts)  [Biography] bio
Date Wed 05 Nov 2008 08:32 PM (UTC)
Message
Iron Realms has just added a nifty feature to their new Flash client that allows it to download a map image and display your current subsection of it in a tiny floating window. Since this URL is sent in an ATCP message, I'm hoping it might be possible to do the same using a miniwindow in MUSHclient.

Is there any feasible way I can download an image from a URL and load a portion of it into a miniwindow? I'm sure I could handle the latter part if I knew how to do the former. :)
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Wed 05 Nov 2008 08:38 PM (UTC)
Message
If you're using Lua, you can use the LuaSocket library:

http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/http.html#request

That requests the data at a given URL and returns it as a string. You could then output it to a file, and do your image drawing from there.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 05 Nov 2008 09:36 PM (UTC)
Message
Yes, and see this post:

http://www.gammon.com.au/forum/bbshowpost.php?id=4935

That shows pulling in stuff from a URL.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Wed 05 Nov 2008 10:15 PM (UTC)
Message
Wow... hard to believe that it's already been four years since we started talking about using Lua. But there you have it. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #4 on Thu 06 Nov 2008 02:11 AM (UTC)
Message
Thanks for the link! I guess I should've done a better search before posting, but I wasn't thinking it would be done through a Lua add-on, hoping maybe there was a MUSHclient function for it that I just hadn't seen yet.

So, it should work fine storing an image, as a binary, in a variable and then writing that to a file? I'm planning to make my own local cache that gets refreshed maybe once a week automatically, to keep from downloading the files every single time I move to a new room in the same zone.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #5 on Thu 06 Nov 2008 07:00 AM (UTC)
Message
Keep in mind that LuaSocket is blocking, there's some code for an asynchronous server in the same Kepler project that LuaSocket is part of, but you'd have to extract and adapt for a client. Otherwise, you might hang the client on a poor connection. The maps seem to be around 30-40KB on average and there's probably around a 100 of them in total, so that runs up to almost half a megabyte, which is guaranteed to give Mushclient a serious "hiccup" even on broadband.

Instead of mucking with scraping IRE maps, I am thinking of a different approach: make a basic automapper and build the maps yourself using the coordinates supplied through ATCP.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #6 on Thu 06 Nov 2008 11:16 AM (UTC)
Message
I've already got a plugin to capture and display the in-game maps, but that lags me a bit, and I think it would actually be speedier to move with the graphical maps once I get past the initial downloading step.

I'm actually contemplating just using a brute force approach to the downloading, however, to avoid hanging the client, as you say. I'll just use a small tool I develop to batch download all the available areas and store them locally.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #7 on Thu 06 Nov 2008 02:44 PM (UTC)
Message
It would probably be acceptable to hang the client just once per map, and then never download it again, instead of trying to work out a cleverer scheme of scraping etc., no?

Incidentally you can tell the socket library to not block. See the example in here:
http://www.lua.org/pil/9.4.html

This shows how you can use coroutines to concurrently download several files.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #8 on Thu 06 Nov 2008 03:28 PM (UTC)
Message
That's a bit more complicated, but it looks like an interesting challenge! I know you're right about downloading these files being a fairly small block, but I was worried about cases where it has troubles connecting and just waits for the maximum timeout.

Thanks again.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Fri 07 Nov 2008 06:15 AM (UTC)
Message
I'm not sure about the binary download - the data may just be in binary or you may need to interpret it somehow (eg. base64).

Doing the asynchronous stuff isn't that hard, it is just a bit fiddly - you have to initiate the IO, then have some way of knowing when it is complete.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


7,713 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]