Simulate a mouse click
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.
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Simulate a mouse click
Is there any way to simulate a single mouse click?
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
Can you give more context of what you want to do and why you want to do it?
Mouse click to do what? Advance text? Press a button?
Mouse click to do what? Advance text? Press a button?
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
trooper6 wrote:Can you give more context of what you want to do and why you want to do it?
Mouse click to do what? Advance text? Press a button?
Yeah advance text. Not simulate a button.
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
What triggers the text to advance? Does it advance after a certain amount of time? After something happens?
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
Well here's the whole problem.trooper6 wrote:What triggers the text to advance? Does it advance after a certain amount of time? After something happens?
I have this code. It's to give a character an item from your backpack. However there's a weird bug.
Code: Select all
label give:
show screen backpack
$ renpy.pause()
#correctly waits for an item to be chosen
$ speakerId = (speaker + "_id")
if (itemGiven == getattr(store, speakerId)):
#incorrectly waits again for a mouse click before changing the expression.
show expression ( speaker + " happy")
$ renpy.say(getattr(store, speaker[0]), "Good Item")
elif (itemGiven == "NULL"):
#incorrectly waits again for a mouse click before changing the expression.
show expression ( speaker + " surprised")
$ renpy.say (getattr(store, speaker[0]), "No item")
else:
#incorrectly waits again for a mouse click before changing the expression.
show expression ( speaker + " disgusted")
$ renpy.say (getattr(store, speaker[0]), "Bad item")
jump expression location
However after an item (or no item is selected) there seems to be a second pause before the expression is shown. That why I wanted to simulate a mouse click. To get rid of this second pause.
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
What does your screen backpack look like?
Do you plan on having the user only press one button on that screen?
If there are any functions you have attached to that screen, what are those functions?
Do you plan on having the user only press one button on that screen?
If there are any functions you have attached to that screen, what are those functions?
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
My backpack screen is pretty simpletrooper6 wrote:What does your screen backpack look like?
Do you plan on having the user only press one button on that screen?
If there are any functions you have attached to that screen, what are those functions?
It's mostly just this
Code: Select all
Imagebutton:
idle "backgrounds/transparent.png"
action [Hide ("backpack"), SetVariable("itemGiven", noItem)]
add "backgrounds/backpack.png"
$ inv_items = inventory.items
for Item in inv_items:
imagebutton:
idle pic
hover h_pic
xpos a
ypos b
action [SetVariable("itemGiven", Item.type), Hide("item_desc"), Hide("item_name"), Hide("backpack")]
hovered [Show(("item_name"), Item = i_name), Show(("item_desc"), Item = i_name)]
unhovered [Hide("item_desc"), Hide("item_name")]
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
That isn't the full screen code it doesn't seem...and there seems to be strangeness with your indentation. Could you post the entire screen code? I want to know if it is modal and the other details of it.
Anyway, If you only plan on having the user press one button, get rid of all the hide stuff in your actions and just call the screen rather than show it. Then you shouldn't need to do the pause at all.
Anyway, If you only plan on having the user press one button, get rid of all the hide stuff in your actions and just call the screen rather than show it. Then you shouldn't need to do the pause at all.
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
That's pretty much the whole screen code. It isn't modal or anything.trooper6 wrote:That isn't the full screen code it doesn't seem...and there seems to be strangeness with your indentation. Could you post the entire screen code? I want to know if it is modal and the other details of it.
If I do call instead of show then the pause becomes permanent and there is no way to advance the game after selecting an item, even by clicking.trooper6 wrote: Anyway, If you only plan on having the user press one button, get rid of all the hide stuff in your actions and just call the screen rather than show it. Then you shouldn't need to do the pause at all.
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
LiveTurkey wrote: That's pretty much the whole screen code. It isn't modal or anything.
Code: Select all
Imagebutton:
idle "backgrounds/transparent.png"
action [Hide ("backpack"), SetVariable("itemGiven", noItem)]
add "backgrounds/backpack.png"
$ inv_items = inventory.items
for Item in inv_items:
imagebutton:
idle pic
hover h_pic
xpos a
ypos b
action [SetVariable("itemGiven", Item.type), Hide("item_desc"), Hide("item_name"), Hide("backpack")]
hovered [Show(("item_name"), Item = i_name), Show(("item_desc"), Item = i_name)]
unhovered [Hide("item_desc"), Hide("item_name")]
This is not what a screen definition looks like. Examples of what screen definitions look like can be found in the screens.rpy file in any new project.
You keep asking for answers to small problems, but without giving the larger overview. I suspect you have a problem with the larger overview. I can give you the quick answer to this question:
Which is: add Return() to your button actions.LiveTurkey wrote:If I do call instead of show then the pause becomes permanent and there is no way to advance the game after selecting an item, even by clicking.
But I feel like there are larger problems with your screen design that should be addressed. I would like to see the *entire* screen definition with annotations of what you want each section to do, to maybe help you end up with something that will work better, more elegantly, and not cause unexpected negative consequences.
In case you don't know what a complete screen definition looks like it would include the line:
Code: Select all
screen backpack():
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
I cleaned it up a bit, here is the full backpack screen but like I said it's pretty much what I already posted.trooper6 wrote:
But I feel like there are larger problems with your screen design that should be addressed. I would like to see the *entire* screen definition with annotations of what you want each section to do, to maybe help you end up with something that will work better, more elegantly, and not cause unexpected negative consequences.
Code: Select all
screen item_desc (Item):
$ description = Item.description
text description pos 205, 525
screen item_name (Item):
$ name = Item.name
text name pos 205, 500
screen backpack:
$ noItem = "NULL"
imagebutton:
idle "backgrounds/transparent.png"
action [Hide ("backpack"), SetVariable("itemGiven", noItem)]
add "backgrounds/backpack.png"
$ amountOfColumns = 3
$ columnPosition = 0
for Item in inventory.items:
$ i_name = Item
imagebutton:
idle Item.image
hover Item.hoverImage
xpos 430+((columnPosition%amountOfColumns)*200)
ypos 230+((columnPosition//amountOfColumns)*200)
action [SetVariable("itemGiven", Item.type), Hide("item_desc"), Hide("item_name"), Hide("backpack")]
hovered [Show(("item_name"), Item = i_name), Show(("item_desc"), Item = i_name)]
unhovered [Hide("item_desc"), Hide("item_name")]
$ columnPosition += 1
Last edited by LiveTurkey on Wed May 24, 2017 4:25 pm, edited 1 time in total.
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
Let me ask some questions.
*Can you explain the first image button? What is backgrounds/transparent.png? Is it actually just a blank/transparent image with nothing on it? Are you just wanting so that if the player presses anywhere on the screen except for the buttons you want it to close? It this button currently working for you? Do you actually need it?
*If you want columns...why aren't you using an hbox? Is there a reason you aren't using it or did you just not know about hboxes?
I'm going to fix this screen for you, I just need a bit more detail about what this is supposed to look like.
*Can you explain the first image button? What is backgrounds/transparent.png? Is it actually just a blank/transparent image with nothing on it? Are you just wanting so that if the player presses anywhere on the screen except for the buttons you want it to close? It this button currently working for you? Do you actually need it?
*If you want columns...why aren't you using an hbox? Is there a reason you aren't using it or did you just not know about hboxes?
I'm going to fix this screen for you, I just need a bit more detail about what this is supposed to look like.
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
I edited the code a bit more and edited my post. The first image button is a completely transparent 1920*1080 image and yes it's purpose is that if the player presses anywhere on the screen except for the buttons, the backpack closes. It is currently working as intended. I didn't use an hbox because I want my backpack screen to actually look like a backpack not those stylized boxes. And the columns and rows implementation works great, I don't think that's the problem.trooper6 wrote:Let me ask some questions.
*Can you explain the first image button? What is backgrounds/transparent.png? Is it actually just a blank/transparent image with nothing on it? Are you just wanting so that if the player presses anywhere on the screen except for the buttons you want it to close? It this button currently working for you? Do you actually need it?
*If you want columns...why aren't you using an hbox? Is there a reason you aren't using it or did you just not know about hboxes?
I'm going to fix this screen for you, I just need a bit more detail about what this is supposed to look like.
And BTW, changing it to call screen instead of show screen and adding Return() seemed to fix my problem. Thanks!
Discord -> https://discord.gg/KPRktG2
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Simulate a mouse click
Do you have a max number of items that can be in the backpack at any given time?
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
- LiveTurkey
- Regular
- Posts: 109
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
- Contact:
Re: Simulate a mouse click
I'm not sure about that honestly. Currently there is no max limit but if I add too many item it starts going off the screen. So I have to either put a cap on the number of items or make my inventory scrollable. Neither have been implemented and I'm not sure which I'm going to pick.trooper6 wrote:Do you have a max number of items that can be in the backpack at any given time?
I don't know if you read my edit to the last post but I fixed the problem (thanks your help)
Changing it to call screen instead of show screen and adding Return() fixed the problem. Thanks!
Discord -> https://discord.gg/KPRktG2
Who is online
Users browsing this forum: No registered users