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
➜ General
➜ Retrieving and displaying a URL
Retrieving and displaying a URL
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Larkin
(278 posts) 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. :) | Top |
|
Posted by
| David Haley
USA (3,881 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Wed 05 Nov 2008 09:36 PM (UTC) |
Message
| |
Posted by
| David Haley
USA (3,881 posts) 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 | Top |
|
Posted by
| Larkin
(278 posts) 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. | Top |
|
Posted by
| Ked
Russia (524 posts) 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. | Top |
|
Posted by
| Larkin
(278 posts) 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. | Top |
|
Posted by
| David Haley
USA (3,881 posts) 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 | Top |
|
Posted by
| Larkin
(278 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | 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.
30,440 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top