Getting content from a web link

  • #1, by bobby23Tuesday, 07. October 2014, 14:58 11 years ago
    Is there a way to get content from a web link BUT without actually going to that link?
    For example :

    In my game I want to have a TV where the player can change channels on a TV. I do not want to show an Image that acts like the website because I want in the future to be able to modify that page. (I want the player to click on Updates on the TV and connect on an webpage which I will be modifying so I can show if there is a new game update)

    Although this sounds quite difficult , in theory it is easy to do since all I have to do is call the TV image from a web link instead from a file that is embedded in the .vis

    So far to point my players to a website (I did a nice little PC/TV with an in-game browser and set Favorites) I was calling :

    startDefaultBrowser('http://www.google.com')

    Which opened a browser for the game and pointed to that website. I set it to change according to what the player was clicking on the remote that he was using but I can't find HOW will I do it so that it changes IN-GAME and not popping a new window like a pop-up.

    Any Ideas?

    Great Poster

    265 Posts


  • #2, by afrlmeTuesday, 07. October 2014, 15:24 11 years ago
    start default browser is for opening up a specific webpage in your default web browser.

    I think what you are asking for might be possible using lua socket. I think David mentioned adding support for it a little while ago for something. I've not looked into it, but maybe he will know how you could do what you are wanting, or something similar.

    Imperator

    7285 Posts

  • #3, by bobby23Tuesday, 07. October 2014, 15:28 11 years ago
    Lets hope he sees this then ^_^

    Great Poster

    265 Posts

  • #4, by BigStansTuesday, 07. October 2014, 16:48 11 years ago
    You can use luasocket functions for that. It's embeded in V4.
    Like:

    local http = require("socket.http")
    http.TIMEOUT = 5
    result = http.request("http://google.com")
    print(result)
    


    for an little example. If you want to try to get an "variable" or something.
    An embedded browser "in game" does not exists. startDefaultBrowser starts the default browser outside the player or in steam the "Default" Steam Browser.

    Great Poster

    361 Posts

  • #5, by BigStansTuesday, 07. October 2014, 18:27 11 years ago
    oh, i see, that i'Ve not included all luasocket functions. It's fixed now and available in the next release.

    I've tested it with the following example to get the title from a youtube video:

    local http = require("socket.http")
    http.TIMEOUT = 5
    
    local result = http.request("http://www.youtube.com/watch?v=iG-RdeuvKUM")
    local title = result:match("([^<]*)<");
    print(title);
    


    Result from example was:
    Dj Rush & Zombie Nation live @ Hafentunnel 2001 - YouTube

    Great Poster

    361 Posts

  • #6, by bobby23Tuesday, 07. October 2014, 21:23 11 years ago
    Thank you
    Do you have a list of the commands?
    Can I import an image from the web?

    like :

    local result = http.request ("http ://images.siteface.net/siteface/2494/l_723_311890_2216741101349_1084866648_n.jpg")

    which will bring up my profile pic here for example
    and then I can set that image to be the background of a scene (or something similar) ?

    Great Poster

    265 Posts

  • #7, by bobby23Tuesday, 07. October 2014, 21:25 11 years ago
    Thats me on the left btw ^_^

    Great Poster

    265 Posts

  • #8, by afrlmeTuesday, 07. October 2014, 23:17 11 years ago
    http://w3.impa.br/~diego/software/luasocket/ There's some information on there explaining some of the things that are possible. I think the most useful thing to do with this might be to access a database or some kind of text table which you could print to a display object text action part or something maybe. It says it has mime support so I assume it has various media & file type support.

    Imperator

    7285 Posts

  • #9, by AkcayKaraazmakWednesday, 08. October 2014, 00:25 11 years ago
    And how we could write the text that we grap from web on the game screen?smile (instead of printing with print)

    Great Poster

    440 Posts

  • #10, by BigStansWednesday, 08. October 2014, 00:55 11 years ago
    Ah, an picture from a webPic. Nice idea smile The luasocket functions are embedded fully in the next release.
    Hm… I think an possible new feature smile Oh ^^ I see Pictures from a webService in the Future smile

    I will ask Simon and Alex about that function smile

    Great Poster

    361 Posts

  • #11, by AlexWednesday, 08. October 2014, 01:07 11 years ago
    And how we could write the text that we grap from web on the game screen?smile (instead of printing with print)


    you could store the text in a value and then display a text with the value. You could also use the text from the website to define condition states which are linked to scene objects (so the objects are visible depending on the condition).

    Great Poster

    378 Posts