Imagebutton action
Posted: Wed May 20, 2020 6:06 am
Hi guys
How to give +1 to a variable when I click on an imagebutton?
How to give +1 to a variable when I click on an imagebutton?
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
Code: Select all
imagebutton auto "whatever_%s.png" action SetVariable("thevariable", thevariable+1)
Code: Select all
$ thevariable = "hello"
Code: Select all
$ thevariable += 1
Code: Select all
imagebutton auto "whatever_%s.png" action If('the_thing == "hello"' , true = [SetVariable("the_variable", thevariable+1)], false = [SetVariable("the_variable", the_variable+2)])
Code: Select all
if the_thing == "hello":
imagebutton auto "whatever_%s.png" action SetVariable("the_variable", the_variable+1)
elif the_thing == "Gas":
imagebutton auto "whatever_%s.png" action SetVariable("the_variable", the_variable+10)
else:
imagebutton auto "whatever_%s.png" action SetVariable("the_variable", the_variable+3)
Code: Select all
button:
action If(
var == 1,
SetVariable("var", var + 1), # true action
If( # false action
var == 2,
SetVariable("var", var + 2), # will happen if var == 2
NullAction()
)
)
Well, if you've started with the full problem since the beginning that helped a lot .iDweadith wrote: ↑Wed May 20, 2020 11:12 am Thanks guys!
Yes! This is it
imagebutton auto "whatever_%s.png" action If('the_thing == "hello"' , true = [SetVariable("the_variable", thevariable+1)], false = [SetVariable("the_variable", the_variable+2)])
but how to add more elif in this line?
In my case I can't use the second example you did Gas
Because I have an inventory with items, and every item is an imagebutton
Code: Select all
screen myscreen (name = "greg")
text "[name]"
Code: Select all
show screen myscreen(name = "gas")
Variables should not be defined this way. This will cause problems with save and rollback.isobellesophia wrote: ↑Wed May 20, 2020 8:49 am I think you need to define first.
Code: Select all
$ thevariable = "hello"
Code: Select all
default thevariable = "hello"
Code: Select all
$ fruits = apples + pears
Code: Select all
default apples = 1
default pears = 2
Code: Select all
label start:
$ peaches = 5
Code: Select all
screen my_screen():
$ my_name = 'Elodie'
Code: Select all
$ my_name = "Gas"
show screen my_screen
e "The name shown is [my_name]!"
screen my_screen():
$ my_name = 'elodie'
Code: Select all
screen my_screen():
the_name = my_name
Code: Select all
screen my_screen (name ="Harry")
$ full_name ="Sir "+name
text "[full_name]"