[solved ]How to add data to a screen from an internet source

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3632
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

[solved ]How to add data to a screen from an internet source

#1 Post by Imperf3kt » Sun Aug 14, 2022 6:16 pm

I asked something similar to this years ago, but cannot find that post and cannot remember how to do this, but I want to be able to add text and images (potentially embedded videos) to a screen, based on the contents of a text file or other which is stored on a web server.

My ultimate goal is to have a screen with information about a specific thing, which sometimes changes and I want to edit that without having to build a new distribution of the game.

I'd also like to be able to embed some YouTube videos (or any other service, maybe even have to host them myself) as my game includes a ton of videos and I'm trying to minimise the size of the game for mobile users

Can anybody point me to an example of how to do this? Which renpy functions will allow it?
Last edited by Imperf3kt on Thu Aug 18, 2022 6:54 am, edited 3 times in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
PyTom
Ren'Py Creator
Posts: 15892
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to add data to a screen from an internet source

#2 Post by PyTom » Sun Aug 14, 2022 9:29 pm

https://www.patreon.com/posts/news-from-your-15636026

Has an articule I wrote up on how to do that. It should mostly be the same now, except that requests is built into Ren'Py by default.

You won't be able to embed videos from youtube, Ren'Py isn't a web browser. You can use OpenURL to link people to a youtube page.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3632
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to add data to a screen from an internet source

#3 Post by Imperf3kt » Sun Aug 14, 2022 10:27 pm

Thanks PyTom, exactly what I needed.

A link to videos will probably suffice for a lite version. The intention was to add tutorials, which may need to be changed over time, so this will also work.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3632
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: [solved ]How to add data to a screen from an internet source

#4 Post by Imperf3kt » Mon Sep 19, 2022 8:19 am

I'm struggling to work out how to use this outside the news screen. Every other screen I try to use it on says missing required positional arguments 'news'
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1842
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: [solved ]How to add data to a screen from an internet source

#5 Post by Ocelot » Mon Sep 19, 2022 8:42 am

Some code will be nice. By default news screen is invoked by ShowNews action which does nessesary things, like passing actual news object to the screen. Does your screen has news parameter? Do you provide it when showing screen? Do you access news in some other way?
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3632
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: [solved ]How to add data to a screen from an internet source

#6 Post by Imperf3kt » Mon Sep 19, 2022 5:11 pm

I didn't add any code because there was none to add.
I am using the default news screen, that works, but I don't want the news screen, I just want the data to appear in another screen.

However, I think you just solved my issue, I wasn't calling my screens using ShowNews action. I was focusing too much on the contents of the screen, rather than the method the screen is shown by.

I'll have to check later, but I think that sounds like what I was missing.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Post Reply

Who is online

Users browsing this forum: enaielei, Google [Bot]