Hello friends!
I am new to renpy and i try to use luck points in one of my projects.
I want them to be at 100 maximum so i use this in my screens:
r_max = 100
r_luck = 1
adding points works alright but somehow when i reach 100 it goes on to 101 , 102 etc so the r_ thing doesnt seem to work?
pls help me
Maximum points? PLS help me.
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.
-
- Regular
- Posts: 169
- Joined: Sun Jun 04, 2017 12:05 pm
- Completed: Too many, check signature
- Deviantart: mikolajspy
- Location: Wrocław, Poland
- Contact:
Re: Maximum points? PLS help me.
Your r_max is just another variable and does not do anything on it's own.
You can, however do something like this, right after adding points:
or you can write a function, so it check automatically when adding like this (put this code somewhere at top of script)
and then use it like this where it should be added:
I think this might work
You can, however do something like this, right after adding points:
Code: Select all
$r_luck += 1 #Adds points to the variable
if r_luck > r_max: # if luck points are greater than max value you want to have...
$r_luck = r_max # set the luck to the maximum value
Code: Select all
init python:
def Add_luck(n):
r_luck += n
if r_luck > r_max:
r_luck = r_max
Code: Select all
$ Add_luck(1)
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Maximum points? PLS help me.
Adding on to what mikolajspy suggests, I do recommend the function approach as I know it works wonderfully. One question though, shouldn't you use global in the function to change the values?
That is, if the r_luck and r_max variables are defined outside of init block, using default, or in the script. Not too sure about that so if I'm wrong I apologize.
Code: Select all
init python:
def Add_luck(n):
global r_luck, r_max #?
r_luck += n
if r_luck > r_max:
r_luck = r_max
The most important step is always the next one.
Re: Maximum points? PLS help me.
Awesome , thank you guys! You helped me alot!
Who is online
Users browsing this forum: Bing [Bot], Majestic-12 [Bot], munni, piinkpuddiin, snotwurm