So I’ll be bit more specific, because I couldn’t figer out how it works and I need the names later to compare colours. (The goeal is to create a master mind game)
Name of cubes: solution1, 2, 3 and 4
They should al have different colors.
I upladed now the blend file.

My scripts for each cube
cube 1
import bge
import random
#I've made different scrips for each cube
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
blue = [0,0,1,True]
green = [0,1,0,True]
red = [1,0,0,True]
yellow = [255,255,0,True]
brown = [0.207917,0.105,0.030,True]
pink = [2.55,0.20,1.47,True]
color = [blue, green, red, yellow, brown, pink]
own.color = random.choice(color)
main()
cube2
import bge
import random
#I've made different scrips for each cube
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
solution1 = bge.logic.getCurrentScene().objects['solution1']
solution2 = bge.logic.getCurrentScene().objects['solution2']
solution3 = bge.logic.getCurrentScene().objects['solution3']
solution4 = bge.logic.getCurrentScene().objects['solution4']
blue = [0,0,1,True]
green = [0,1,0,True]
red = [1,0,0,True]
yellow = [255,255,0,True]
brown = [0.207917,0.105,0.030,True]
pink = [2.55,0.20,1.47,True]
color = [blue, green, red, yellow, brown, pink]
own.color = random.choice(color)
#Part for solution1
if solution1 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution1 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution1 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
main()
cube3
import bge
import random
#I've made different scrips for each cube
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
solution1 = bge.logic.getCurrentScene().objects['solution1']
solution2 = bge.logic.getCurrentScene().objects['solution2']
solution3 = bge.logic.getCurrentScene().objects['solution3']
solution4 = bge.logic.getCurrentScene().objects['solution4']
blue = [0,0,1,True]
green = [0,1,0,True]
red = [1,0,0,True]
yellow = [255,255,0,True]
brown = [0.207917,0.105,0.030,True]
pink = [2.55,0.20,1.47,True]
color = [blue, green, red, yellow, brown, pink]
own.color = random.choice(color)
#Part for solution1
if solution1 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution1 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution1 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
#Part for solution2
if solution2 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution2 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution2 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
main()
cube4
import bge
import random
#I've made different scrips for each cube
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
solution1 = bge.logic.getCurrentScene().objects['solution1']
solution2 = bge.logic.getCurrentScene().objects['solution2']
solution3 = bge.logic.getCurrentScene().objects['solution3']
solution4 = bge.logic.getCurrentScene().objects['solution4']
blue = [0,0,1,True]
green = [0,1,0,True]
red = [1,0,0,True]
yellow = [255,255,0,True]
brown = [0.207917,0.105,0.030,True]
pink = [2.55,0.20,1.47,True]
color = [blue, green, red, yellow, brown, pink]
own.color = random.choice(color)
#Part for solution1
if solution1 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution1 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution1 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution1 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
#Part for solution2
if solution2 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution2 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution2 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution2 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
#Part for solution3
if solution3 == red:
color = [blue, green, yellow, brown, pink]
own.color = random.choice(color)
elif solution3 == green:
color = [blue, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution3 == blue:
color = [green, red, yellow, brown, pink]
own.color = random.choice(color)
elif solution3 == yellow:
color = [blue, red, green, brown, pink]
own.color = random.choice(color)
elif solution3 == pink:
color = [blue, red, yellow, brown, green]
own.color = random.choice(color)
elif solution3 == brown:
own.color = green
color = [blue, red, yellow, green, pink]
own.color = random.choice(color)
main()
Attachments
Fix.blend (9.84 MB)