Hi team,
It's late and I'm probably just plain missing what's glaringly obvious to everyone else, but I'm trying to make a conditional imagebutton work and it's throwing a hissyfit.
imagebutton auto "phonewatch_%s.png" action If("time <= 3", AddToSet(time, 1), Jump("sallybed")) align (0.01,0.04)
I have a variable for time ("default time = 0" in the pre-start definitions) which, if clicked, the imagebutton should add one to. Once the time variable raises to 4 and the imagebutton is clicked again, it should jump to the 'sallybed' label in the script.
When trying to run it like that, I get:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/loc-stbedroom.rpy", line 253, in script
scene bg stbathroom with dissolve
File "renpy/common/00action_data.rpy", line 411, in get_sensitive
return self.value not in self.set
TypeError: argument of type 'int' is not iterable
Is it the "time <= 3" section or the AddToSet bit that I'm getting wrong? I thought AddTOSet was right for simply advancing a numerical counter but could be way off there...
Thanks!
Conditional imagebutton [SOLVED]
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: 33
- Joined: Sat May 04, 2019 8:09 am
- Contact:
Conditional imagebutton [SOLVED]
Last edited by HammeredEnt on Wed Jan 29, 2020 5:44 am, edited 1 time in total.
- 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: Conditional imagebutton
What is time? A set or an int?
Maybe?
Code: Select all
default time = 0
screen a():
imagebutton auto "phonewatch_%s.png" action If(time <= 3, SetVariable('time', time+1), Jump("sallybed")) align (0.01,0.04)
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
Re: Conditional imagebutton
AddToSet is for other types than ints (it append that value to the end of a list or set).
You need SetVariable("time", time+1).
(Sorry, I wrote it the same exact moment the above reply!)
You need SetVariable("time", time+1).
(Sorry, I wrote it the same exact moment the above reply!)
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
-
- Regular
- Posts: 33
- Joined: Sat May 04, 2019 8:09 am
- Contact:
Re: Conditional imagebutton
Thanks to both of you for replying! Yes, time was an int, so the amendment to SetVariable was just the guidance I needed to get that aspect working.
However, while it's functioning, it's not being conditional - it just keeps running true regardless of the "time" variable being at 4 or higher.
action If("time <= 3", SetVariable("time", time+1), Jump("sallybed"))
Have I got my syntax wrong somewhere? I tried swapping around the true and false returns and it kept doing the same thing of running the true return.
However, while it's functioning, it's not being conditional - it just keeps running true regardless of the "time" variable being at 4 or higher.
action If("time <= 3", SetVariable("time", time+1), Jump("sallybed"))
Have I got my syntax wrong somewhere? I tried swapping around the true and false returns and it kept doing the same thing of running the true return.
- Angelo Seraphim
- Regular
- Posts: 36
- Joined: Tue May 21, 2019 8:00 am
- Completed: Enamored Risks (NaNoReNo 2020)
- Projects: 616 Charagma
- Organization: GLSUoA
- Deviantart: glsuoa
- itch: glsuoa
- Location: London, UK
- Discord: Just A Concept#9599
- Contact:
Re: Conditional imagebutton
Should be:
time <= 3 without the quotes. (That's probably with it's running "true" all the time.)
So just a quick summary;
time <= 3 :: time has to be less than or equal to 3 to be true, otherwise it will be false.
Code: Select all
action If(time <= 3, SetVariable("time", time + 1), Jump("sallybed"))
So just a quick summary;
time <= 3 :: time has to be less than or equal to 3 to be true, otherwise it will be false.
-
- Regular
- Posts: 33
- Joined: Sat May 04, 2019 8:09 am
- Contact:
Re: Conditional imagebutton
Ah-hah! That was it, thank you! Thanks everyone for their help with this!
Who is online
Users browsing this forum: No registered users