Here is the code that does what you are looking for:
Code: Select all
default mixer = "none"
image redSquare = Solid("#ff0000",xsize=100,ysize=100)
image greenSquare = Solid("#00ff00",xsize=100,ysize=100)
image blueSquare = Solid("#0000ff",xsize=100,ysize=100)
image switchSquare = ConditionSwitch(
"mixer == 'red'", "redSquare",
"mixer == 'green'", "greenSquare",
"True", "blueSquare")
screen tester():
imagebutton:
idle "switchSquare"
hover "switchSquare"
action NullAction()
label start:
"Just testing."
show screen tester()
"Starting blue"
$mixer = "red"
"Now Red"
$mixer = "green"
"Now Green"
return
So comparing your code and my code. From top to bottom.
1) Don't put your defaults and image declarations inside an init block. Renpy does all of this.
2) For your ConditionSwitch, make sure one condition is always true. For your button, I suspect it will be when mixer_left is equal to "none"--so put that last in your ConditionSwitch and have the condition just be True instead.
3) You need to put single quotes around things you want to be strings inside that ConditionSwith string, otherwise it thinks you are talking about a variable.
So this:
translates to: if the variable named mixer_left is equal to the variable named purple_chemical. But you don't have a variable named purple_chemical. You want to talk about strings.
This (which is what you want):
translates to: if the variable named mixer_left is equal to the string "purple_chemical"
4) in your screen, when you declare your idle and hover images, they need to be in quotation marks because the Imagebutton object expects a string after those properties, you can imply this by looking at the documentation for Imagebutton under the first property "auto" where it reads:
Used to automatically define the images used by this button. This should be a string that contains %s in it.
idle and hover don't need the %s, they'll just have idle and hover explicitly stated, but the property still expects a string.
So put your mixer_left_idle_image in quotations.
5) That is not how you do a SetVariable action. (
https://www.renpy.org/doc/html/screen_a ... etVariable)
Following the documentation it should look like so:
Code: Select all
SetVariable("mixer_left", "helditem")
But note, if you are adding to a numerical value say you have a:
default mixer_num = 0
and you want your SetVariable action to add to that number, that would look like this:
Code: Select all
action SetVariable("mixer_num", mixer_num+1)