Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
-
Crazy Li
- Regular
- Posts: 113
- Joined: Fri Jan 03, 2014 3:35 pm
-
Contact:
#1
Post
by Crazy Li » Sat Jul 13, 2019 5:03 am
So I built a custom battle engine for my game... a pretty simple, menu-based dealy where I mimic the regular dialogue textbox and have options in there you click to do things in the battle. The system is handled within a screen "battle" that I have shown when it's time to initiate. Yeah, I probably should have
called the screen instead of showing it, but I was having a lot of issues getting it to function that way, so I did what worked... and for the most part, it does. It displays the battle choices when it's the player's turn, clicking the options work as intended. When the battle ends, it goes back to the game, jumping wherever it needs too. There's just one problem... if you click anywhere BUT one of the battle options the first time the screen pops up (or use text skip without clicking anything), the game just starts running the next line of the story while the battle is still running and the two just overlap. This only happens when the screen is first shown. If I click an option proper the first time, clicking outside the choices doesn't try to proceed past the battle, and instead properly stays contained within. I'm not sure why it only occurs the first time around.
This is the code I use to initiate battles:
Code: Select all
window hide
show screen battle
pause
Last edited by
Crazy Li on Sat Jul 13, 2019 4:04 pm, edited 1 time in total.
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#2
Post
by Alex » Sat Jul 13, 2019 5:25 am
You see, showing the screen doesn't stop the game flow, so clicking will proceed the game for next line of code.
When you call the screen, the game flow stops and waits for user interaction, so just clicking doesn't make game procced - the screen must return a value.
The other way, you can set the modal property of the screen to True, so player will be forced to operate with this screen only -
https://www.renpy.org/doc/html/screens. ... -statement
Also, this (and the next post) might be useful for you -
viewtopic.php?f=51&t=18047&start=15#p395926
-
Crazy Li
- Regular
- Posts: 113
- Joined: Fri Jan 03, 2014 3:35 pm
-
Contact:
#3
Post
by Crazy Li » Sat Jul 13, 2019 4:04 pm
Well I'm not using "menu" to present the options because it looks terrible. This is why I built my own screen for the sake of the choices. It looks a lot better. Like I said, the battle system works perfectly fine beyond the clicking outside its components still doing stuff (and as a result, it progressing the game the first time). Adding the "modal" attribute to the screen seems to completely fix this though and as far as I can tell, has no negative consequences... so thanks for that tip!
Users browsing this forum: No registered users