[solved] Is it possible to import and show the battery percentage of your phone?

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
Nanahs
Regular
Posts: 171
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

[solved] Is it possible to import and show the battery percentage of your phone?

#1 Post by Nanahs » Fri Oct 05, 2018 5:19 pm

There's a real time clock on my game (for mobile).
I was wondering if I could also import and show the phone's charge percentage like that (the 49%):

Image

So that the person can be aware of the status.

I'm not sure if Renpy can do that.

Thanks :)
Last edited by Nanahs on Thu Nov 08, 2018 9:42 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15270
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: Is it possible to import and show the battery percentage of your phone?

#2 Post by PyTom » Sun Oct 07, 2018 2:28 pm

You can get it using:

Code: Select all

pygame_sdl2.power.get_power_info().percent
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

Nanahs
Regular
Posts: 171
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to import and show the battery percentage of your phone?

#3 Post by Nanahs » Mon Oct 08, 2018 10:21 am

PyTom wrote:
Sun Oct 07, 2018 2:28 pm
You can get it using:

Code: Select all

pygame_sdl2.power.get_power_info().percent
Thank you so much! I couldn't make it work (cause I'm still learning what those things mean and how to place them hah). But thank you anyway. I'll study more :)

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

Re: Is it possible to import and show the battery percentage of your phone?

#4 Post by Imperf3kt » Thu Nov 08, 2018 4:12 am

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Nanahs
Regular
Posts: 171
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to import and show the battery percentage of your phone?

#5 Post by Nanahs » Thu Nov 08, 2018 5:44 pm

Oh! Thank you so much! This is exactly what I was looking for. Thanks for sharing :)

Post Reply

Who is online

Users browsing this forum: No registered users