Once upon a time, a timer was created that works even after exiting the game, as well as modified by Mr. Python, and I often receive requests from familiar mobile developers to upgrade it.
viewtopic.php?f=51&t=47774
the bottom line is, users rewind time, and it makes no sense for them to buy buffs to speed up time in their mobile farms.
the first thing that came to my mind was checking the time via the Internet.
I found one site, and the corresponding module so that users can use json ,
https://pypi.org/project/world-time-api/
http://worldtimeapi.org/
but then there is a 2 problem, how to prevent the application from starting if there is no Internet access?
help please
modification of the timer and prohibition of launching the application without the Internet
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.
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.
modification of the timer and prohibition of launching the application without the Internet
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Re: modification of the timer and prohibition of launching the application without the Internet
Rough idea:
Maybe make a python function that does all the job and if necessary call some label like bad_connection with an option to try and reconnect(or call screen in new context). Possibly put this function in some callbacks (Configuration Variables) and/or some part of the game that is supposed to check the time before doing anything.
Function:
1) To reduce internet connection or not completely avoid offline mode, introduce variables last_internet_time and last_system_time.
Code: Select all
# just logic, not actual code
if (current_system_time > last_internet_time and
current_system_time > last_system_time and
current_system_time - last_internet_time < 4 hours):
last_system_time = current_system_time
return
else
#check internet time
Code: Select all
try:
#retrieve internet time
except:
#call bad_connection
Re: modification of the timer and prohibition of launching the application without the Internet
https://github.com/valery-iwanofu suggested:
1) Through requests, you can do this:
2) You can also install the package via pip, but for this you need a downloaded python:
pip install —target game/python-packages world-time-api
And then use the API of this package
then I will dig thoroughly in this direction, thank you for your help
1) Through requests, you can do this:
Code: Select all
import requests
time_data = requests.get('http://worldtimeapi.org/api/timezone/Etc/UTC').json()
2) You can also install the package via pip, but for this you need a downloaded python:
pip install —target game/python-packages world-time-api
And then use the API of this package
then I will dig thoroughly in this direction, thank you for your help
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Re: modification of the timer and prohibition of launching the application without the Internet
author 7dots
https://store.steampowered.com/curator/29064054
https://pastebin.com/Hd0XnvXU
it remains to solve the problem with the error when there is no Internet
https://www.renpy.org/doc/html/label.ht ... ew_context
use this code, and
...there will be trouble with saving...
https://store.steampowered.com/curator/29064054
https://pastebin.com/Hd0XnvXU
Code: Select all
a timer on renpy that checks time over the internet
init python:
import requests
import datetime
# get current datetime from site
def get_worldtime():
res = None
try:
# get data from worldtimeapi.org
data = requests.get('http://worldtimeapi.org/api/timezone/Etc/UTC').json()["datetime"]
# convert string to datetime format
res = datetime.datetime.fromisoformat(data)
except requests.RequestException as e:
renpy.notify("Something wrong: " + str(e))
return res
# using sample
def check_time():
world_now = get_worldtime().timestamp()
now = datetime.utcnow().timestamp()
# do what you want
# ***
dt = now - world_now
renpy.notify(str(dt))
label start:
# test
# $ check_time()
# $ t = get_worldtime()
# "[t]"
python:
now = datetime.utcnow().timestamp()
world_now = get_worldtime().timestamp()
dt = now - world_now
$ xxx = str(dt)
"No pause: [xxx]"
python:
now = datetime.utcnow().timestamp()
renpy.pause(2)
world_now = get_worldtime().timestamp()
dt = now - world_now
$ xxx = str(dt)
"With pause: [xxx]"
return
https://www.renpy.org/doc/html/label.ht ... ew_context
use this code, and
Code: Select all
python:
..now = somehow_get_local_time()
..server_now = somehow_get_server_time()
if server_now is None:
..call bad_connection
...there will be trouble with saving...
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], snotwurm