I don't know how you structured your game or exactly what kind of game mechanics you're going for, but it seems like jumping to a renpy label from code that's being called after every python block would be a bad idea in general.
I would seriously just give the DSE a look. Poke at it and see how it's set up -- the scheduler and code you can run at the start of each day with the scheduler, an event runner to handle activities that are picked, then a loop back to the scheduler. You don't have to use it in full, but the logic and mechanics will help you set up your own game.
Global variables - Set max and min values
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.
Re: Global variables - Set max and min values
This will do as you ask:cardium wrote:Yeah this is what I initially have done thank you. But I want to change and check my value in every action, so PyTom solution was more appropriate for my problem. Now I am trying to find how to Jump after the if in that code for example:
renpy.jump(label) or renpy.jump_out_of_context(label) are not working, but I will think of something. Thanks again!Code: Select all
init python: def limit_stats(): try: if store.energy < 0: store.energy = 0 renpy.jump("need_sleep") elif store.energy > 100: store.energy = 100
Code: Select all
init python:
def limit_stats():
if hasattr(store, "energy"):
if store.energy < 0:
store.energy = 0
renpy.jump("need_sleep")
elif store.energy > 100:
store.energy = 100
config.python_callbacks.append(limit_stats)
I'd suggest to use a <= operator or nothing will happen if energy just reaches 0 and not below.
-
- Newbie
- Posts: 3
- Joined: Mon Jul 24, 2017 4:49 pm
- itch: Abhainnairgid
- Contact:
Re: Global variables - Set max and min values
How to do this now? I tried putting in the code and it said "indentation mismatch", did I just do it wrong?
This is what I put (in the options file).
This is what I put (in the options file).
Code: Select all
init python:
def limit_stats():
try:
if Health < 0:
Health = 0
elif Health > 100:
Health = 100
except:
pass
config.python_callbacks.append(limit_stats)
Re: Global variables - Set max and min values
Lines with "try:" and "except:" must have equal number of spaces (be indent the same). For now "try:" has 11 spaces and "except:" has 10 spaces - change it.
https://www.renpy.org/doc/html/language ... and-blocks
https://www.renpy.org/doc/html/language ... and-blocks
-
- Newbie
- Posts: 3
- Joined: Mon Jul 24, 2017 4:49 pm
- itch: Abhainnairgid
- Contact:
Re: Global variables - Set max and min values
Okay, that fixed it, thank you!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot]