[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
User avatar
Nanahs
Veteran
Posts: 310
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 »

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: 16088
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 »

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
Software > Drama • https://www.patreon.com/renpytom

User avatar
Nanahs
Veteran
Posts: 310
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 »

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
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

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

#4 Post by Imperf3kt »

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

Current project: GGD Mentor

Twitter

User avatar
Nanahs
Veteran
Posts: 310
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 »

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: Ahrefs [Bot]