So I am doing good with my progress thus far just sorted out how to use the if system and True/False variables to trigger different content based on past choices player made. So now I am writing away the script for dialogue in another easier to storyboard up program so I can swap order of scenes and what not at will, and it hit me I want to use some numerical variables as well like a_like or a_romance then set off a event if they hit a_romance = 10 do a little event with the girl, then flip on the tag a_romance_event1= True
I am doing content with idea of player repeating some common interactions here and there with the characters and using that to build up their score to trigger the next stage from strangers to acquaintances and what not so relations ship builds up over time. So as much as I live the True/False set up I am looking at adding variable with numeric values as well, to give it more depth.
I got a pal who knows python who was saying I should be able to just ad a_romance +=1 to get a plus one to the players score but he knows python not renpy, and also isn't clear on how I define it as a variable but made sure to remind me before I defined it I started writing that into the script. I found lots of guides on basic True/false variables but nothing on numerical value ones.
Adding/defining Numerical Variables
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: 76
- Joined: Fri Mar 09, 2018 6:13 pm
- Projects: A Bureau of Monsters
- itch: pumpkin-spike
- Location: A Pumpkin Patch
- Contact:
Re: Adding/defining Numerical Variables
You can define a numerical variable at the beginning (before label start)
Then, to change it throughout the script
or
The single = sign is important since that means you're setting/changing the value of the variable. It is better in practice to use the first one (the one your friend mentioned).
To compare:
The double equal sign is for comparing. You can also use << for less than a certain number of points, or >> for greater than a certain number of points.
Code: Select all
default a_romance = 0
Code: Select all
$ a_romance+= 1
Code: Select all
$ a_romance = romance + 1
To compare:
Code: Select all
if a_romance == 10:
jump event
Re: Adding/defining Numerical Variables
Thanks I figured it was easier then I thought, now the fun part writing story, in script format with these codes, and sorting out how I use multiple .rpy files I seen others do for their games like having one for each characters event chain...
Re: Adding/defining Numerical Variables
You just create the multiple script files (make sure they have extension .rpy) and put it anywhere inside your game/ folder. Renpy automatically crawl through your folders looking for .rpy files.
Be careful if you ever rename your .rpy files, you'll need to rename / delete the corresponding .rpyc file.
The way Renpy works is: every time you launch your game, all the .rpy file gets compiled into .rpyc files, and all the .rpyc files found will be loaded. When you rename a .rpy file, it'll generate a new .rpyc file at launch, the old .rpyc doesn't get touched. This means you'll end up with two copies of the same compiled script file, and you'll have label and variable collisions and other things.
Be careful if you ever rename your .rpy files, you'll need to rename / delete the corresponding .rpyc file.
The way Renpy works is: every time you launch your game, all the .rpy file gets compiled into .rpyc files, and all the .rpyc files found will be loaded. When you rename a .rpy file, it'll generate a new .rpyc file at launch, the old .rpyc doesn't get touched. This means you'll end up with two copies of the same compiled script file, and you'll have label and variable collisions and other things.
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Adding/defining Numerical Variables
Just as an aside:
pumpkin spike probably meant <= (less than or equal to) and >= (greater than or equal to)
>> and << in python are used for bit shifting and will likely really confuse a non programmer:
27 << 2 = 108 ... ( 27 is 11011 in binary, left shift 2 is 1101100 which is 108 in decimal )
pumpkin spike probably meant <= (less than or equal to) and >= (greater than or equal to)
>> and << in python are used for bit shifting and will likely really confuse a non programmer:
27 << 2 = 108 ... ( 27 is 11011 in binary, left shift 2 is 1101100 which is 108 in decimal )
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
-
- Regular
- Posts: 76
- Joined: Fri Mar 09, 2018 6:13 pm
- Projects: A Bureau of Monsters
- itch: pumpkin-spike
- Location: A Pumpkin Patch
- Contact:
Re: Adding/defining Numerical Variables
Yes! I did, sorry about that, thank you for explaining it!Remix wrote: ↑Fri Jun 15, 2018 5:24 am Just as an aside:
pumpkin spike probably meant <= (less than or equal to) and >= (greater than or equal to)
>> and << in python are used for bit shifting and will likely really confuse a non programmer:
27 << 2 = 108 ... ( 27 is 11011 in binary, left shift 2 is 1101100 which is 108 in decimal )
Who is online
Users browsing this forum: Ocelot