Running up against the hard edge of Python coding versus RenPy formatting...
I want to try and craft a sort of "frequency" puzzle - like attempting to locate the right station on a radio - but essentially structured like a "guess the number" puzzle, with multiple knobs adjusting different elements. I figured the best way to do this is mock up a flat difference between values - so adjustments with the major knob are easily parsed - and the way I could basically figure it is this:
SET_FREQ = this would be the total desired frequency.
SELECTED_FREQ = the total number the player chose.
The tell in this is a display of how far the player is from the actual number, in obfuscated percentage form. This is to make it less apparent if you're higher or lower than the actual SET_FREQ number. Basically, I'd be subtracting one number from another, then dividing the remainder by the SET_FREQ and presenting it as a percentage.
if SET_FREQ > SELECTED_FREQ:
(((SET_FREQ - SELECTED_FREQ) / SET_FREQ) x 100) = PERCENTAGE_FREQ
else
(((SELECTED_FREQ - SET_FREQ) / SET_FREQ) x 100) = PERCENTAGE_FREQ
"Synchronization is within %(PERCENTAGE_FREQ)d percent."
So for a situation where
SET_FREQ = 50
SELECTED_FREQ = 25
(((50 - 25) / 50) x 100) = 0.5
or
SET_FREQ = 50
SELECTED_FREQ = 75
(((75 - 50) / 50) x 100) = 0.5
Granted, I'm going this on WAY too little sleep, but the mathing seems accurate - the issue for me is exactly how I should best construct the code. If i have this I feel like I could lock down the rest of the issue (as well as saving time with graphical requirements since I'll have the text itself display the closeness to completion)
Thanks! (And apologies for this being slightly scatterbrained)
How best to parse math and variables in RenPy?
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.
- AnnieTiamat
- Regular
- Posts: 53
- Joined: Tue Dec 01, 2015 3:24 pm
- Location: Seattle
- Contact:
- Milkymalk
- Miko-Class Veteran
- Posts: 762
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: How best to parse math and variables in RenPy?
I'm not sure I understand your problem.
You could call a screen where the player selects his frequency, return the value, make the calculations, output the result and put all that in a loop that goes on until you have 100%.
You could call a screen where the player selects his frequency, return the value, make the calculations, output the result and put all that in a loop that goes on until you have 100%.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- 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: How best to parse math and variables in RenPy?
Try a bar...
Something like that or StaticValue... Forum search on either value class name should yield some examples.
Other bar Value classes
Code: Select all
screen percent_bar:
vbox:
label _('Precision')
bar value AnimatedValue(PERCENTAGE_FREQ, 100, 0.1)
Other bar Value classes
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
- AnnieTiamat
- Regular
- Posts: 53
- Joined: Tue Dec 01, 2015 3:24 pm
- Location: Seattle
- Contact:
Re: How best to parse math and variables in RenPy?
A little more detail:
Right now I'm running up against the rough edge of what is possible with time and graphical constraints, so I'm basically trying to run with puzzles that can be handled via the choice menu system (i.e. simple player response, not something liek hotspots - that's been a whole other issue!) I'm hoping to do a really simple response output in text, similar to the "Coins left = %(coins)d" print, only with some calculations proceeding.
Basically the flow should be as follows:
If it helps to describe it in player story form:
Right now I'm running up against the rough edge of what is possible with time and graphical constraints, so I'm basically trying to run with puzzles that can be handled via the choice menu system (i.e. simple player response, not something liek hotspots - that's been a whole other issue!) I'm hoping to do a really simple response output in text, similar to the "Coins left = %(coins)d" print, only with some calculations proceeding.
Basically the flow should be as follows:
- - Player is presented with a "frequency" to match (really, this is just an obfuscated guess-the-number puzzle, where the knobs control scaled values - A = +/-100, B = +/-10, C = +/- 1, or something like that. I'll set some safeguard for them not exceeding a ceiling or floor value in scripting, so you can't basically pull C into B range, and B into A, etc.)
- Through dialogue options, player can pick which knob to turn - A, B, or C - and what direction - left or right - to bring them towards the desired "frequency" (i.e. value)
- The difference the player is from that value will ideally be out-put as a text value, as "value is X% away from goal" - something to ideally just tell them roughly how far they are, not if their value is greater or less than the desired one.
- My original thought with this was to show a manipulated sine wave image, but the amount of images I'd have to create to really help the player solve the puzzle would be both cumbersome AND of dubious aid once you really started getting close to the solution.
If it helps to describe it in player story form:
- - The puzzle asks you to "Manipulate the knobs left and right to find the correct frequency. The larger the knob, the greater impact it has on the value. The readout should show you how far you are away from the desired value*." Readout initially reads 80%.
- Player tweaks Knob A to the left several times - the value reduces, then jumps back up at the third bump to the left, so the player corrects with one to the right. Readout says they're at 54%.
- Player tweaks Knob B to the right, then left several times, until the value closeness bottoms out at 5%.
- Player tweaks Knob C, and brings the value to 0%.
- Puzzle solved!
Who is online
Users browsing this forum: maryannette