Disabling the left click. [CLOSED]
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.
- CrunchyShadow
- Regular
- Posts: 46
- Joined: Tue Feb 17, 2015 11:00 pm
- Projects: Seinaru Ai
- Location: Canada
- Contact:
Disabling the left click. [CLOSED]
I'm trying to do something, long story short I need be able to disable the left mouse click for a certain amount of time. As in I'll leave a statement "Pause mouse here" and then write something and then "Resume mouse here". Is there a function for this? Anything? Thank you this is important to my game.
Last edited by CrunchyShadow on Thu Mar 05, 2015 1:13 am, edited 5 times in total.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Disabling the left click.
Create a screen that disables the keybinding of the left mouse click like so:
When you want the user not to be able to use the left click show the screen:
When you want the user to be able to left click again, hide the screen:
However, please note, as per the page on Customizing the Keymap, http://www.renpy.org/doc/html/keymap.html, there are five different ways to dismiss text, the left click on the mouse is only 1, the Return Key, Space Bay, Enter Key, and Joystick Dismiss button are all other ways to dismiss text.
Code: Select all
screen disable_Lmouse():
key "mouseup_1" action NullAction()
Code: Select all
show screen disable_Lmouse()
Code: Select all
hide screen disable_Lmouse
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- CrunchyShadow
- Regular
- Posts: 46
- Joined: Tue Feb 17, 2015 11:00 pm
- Projects: Seinaru Ai
- Location: Canada
- Contact:
Re: Disabling the left click.
Thank you, I'll experiment with how to disable all other functions as well.
- CrunchyShadow
- Regular
- Posts: 46
- Joined: Tue Feb 17, 2015 11:00 pm
- Projects: Seinaru Ai
- Location: Canada
- Contact:
Re: Disabling the left click.
Ummm this seems to do nothing. I'm still able to left click. It seems to completely disregard it,
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Disabling the left click.
Create a new project and put this exact code in the script.rpy file and you should see that the screen works to disable the left mouse click:
This code works for me...so it should work for you as well.
Oh, as a sidenote. If you have a button that moves the game forward, left clicking on that button still moves the game forward, even if you've put a NullAction on the left click. In my game I originally completely disabled all dismiss functions (because I wanted to force people to left click my CTC button to advance the game)...if you completely disable all dismiss functions and have no button or other means to move forward in the game...your game will get stuck...so I don't recommend doing that. I have since returned functionality to the space bar/return key/enter key...but still have disabled the left_click.
If you just want to disable dismiss for a certain amount of time so people are forced to watch an animation for example, I believe people generally recommend the hard pause.
$ renpy.pause(1.0, hard='True')
That pauses for 1 second.
Code: Select all
define e = Character('Eileen', color="#c8ffc8")
screen disable_Lmouse():
key "mouseup_1" action NullAction()
# The game starts here.
label start:
e "This is a test of the disabling of the mouse."
e "Right now should still be able to click through."
e "After this text you shouldn't be able to click through with the mouse any longer, but you should be
able to forward through this with the space bar, the return key, or the enter key."
show screen disable_Lmouse()
e "No longer able to click through."
e "Still not able to click through...ha ha ha."
hide screen disable_Lmouse
e "Okay, now you can click through."
e "End of the test."
return
Oh, as a sidenote. If you have a button that moves the game forward, left clicking on that button still moves the game forward, even if you've put a NullAction on the left click. In my game I originally completely disabled all dismiss functions (because I wanted to force people to left click my CTC button to advance the game)...if you completely disable all dismiss functions and have no button or other means to move forward in the game...your game will get stuck...so I don't recommend doing that. I have since returned functionality to the space bar/return key/enter key...but still have disabled the left_click.
If you just want to disable dismiss for a certain amount of time so people are forced to watch an animation for example, I believe people generally recommend the hard pause.
$ renpy.pause(1.0, hard='True')
That pauses for 1 second.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- CrunchyShadow
- Regular
- Posts: 46
- Joined: Tue Feb 17, 2015 11:00 pm
- Projects: Seinaru Ai
- Location: Canada
- Contact:
Re: Disabling the left click.
Hard Pause is not working... it says "True" is not defined?
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Disabling the left click. [ACTIVE]
So let me explain to you what I did to answer your question, so maybe you can do the same for yourself in the future.
So you say hard pause isn't working and true is not defined.
So I got to the renpy documentation website: http://www.renpy.org/doc/html/
Then I search in the search bar for hard pause and found this page: http://www.renpy.org/doc/html/other.html#renpy.pause
I read it and it notes using the hard pause disables clicking for however long the pause is for. I wonder what effect this might have on hitting the other dismiss buttons (return, enter, space bar)...so I should probably test that, too. It looks like the True or False for hard should be without quotes.
So I create a text project using what I've read about on this page that I looked up.
This is what I wrote:
This code works for me...just like my mouse screen code works for me. While it was paused I also tried the space bar, return and enter key. They don't work during the hard pause.
So if you have a predetermined time you want the game to completely pause, use the hard pause. For other situations your the keybinding screens.
The documentation has a lot of really interesting things. When people ask questions on here, I often don't actually know the answer off the top of my head...I usually do a search--first in the documentation and second in the questions and announcements thread here on the forums. Sometimes I might have to search the general web for python info. Then I make a test project and test out some very simple code.
Works for me!
So you say hard pause isn't working and true is not defined.
So I got to the renpy documentation website: http://www.renpy.org/doc/html/
Then I search in the search bar for hard pause and found this page: http://www.renpy.org/doc/html/other.html#renpy.pause
I read it and it notes using the hard pause disables clicking for however long the pause is for. I wonder what effect this might have on hitting the other dismiss buttons (return, enter, space bar)...so I should probably test that, too. It looks like the True or False for hard should be without quotes.
So I create a text project using what I've read about on this page that I looked up.
This is what I wrote:
Code: Select all
label start:
e "This is a test of the hard pause. After you click, it should pause for 5 seconds without me being able to clickthrough and then go to the next line."
$ renpy.pause(5.0, hard=True)
e "This line shows up after 5 seconds."
So if you have a predetermined time you want the game to completely pause, use the hard pause. For other situations your the keybinding screens.
The documentation has a lot of really interesting things. When people ask questions on here, I often don't actually know the answer off the top of my head...I usually do a search--first in the documentation and second in the questions and announcements thread here on the forums. Sometimes I might have to search the general web for python info. Then I make a test project and test out some very simple code.
Works for me!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Who is online
Users browsing this forum: Majestic-12 [Bot]