Scene.my.Color = Scene.my.Color problems.
6 posts • Page 1 of 1
Scene.my.Color = Scene.my.Color problems.
I want one object (on contact with a laser) to change the color of another object.
Where and how do i put the command for both of the objects?
I know one object needs to recieve the command and the other needs to give the command.
but how do I actually get it to work?
I have some color values set but I'm confused how to get it "carried over" to the other object.
I know its a really simple painfully obvious thing. but how do i do it? o.O
I've tried putting scene.my.color into the "color" section of the object..... but it doesn't want to take it there..
Noticed something though. Even if I do simply put scene.my.color into the box and press enter. then close the menu. It correctly changes color. but then the script INSTANTLY resets to the color it's set to. How do I fix this? Do I put the scene.my.color into a different place? or do i need a more complex way to do this?
Where and how do i put the command for both of the objects?
I know one object needs to recieve the command and the other needs to give the command.
but how do I actually get it to work?
I have some color values set but I'm confused how to get it "carried over" to the other object.
I know its a really simple painfully obvious thing. but how do i do it? o.O
I've tried putting scene.my.color into the "color" section of the object..... but it doesn't want to take it there..
Noticed something though. Even if I do simply put scene.my.color into the box and press enter. then close the menu. It correctly changes color. but then the script INSTANTLY resets to the color it's set to. How do I fix this? Do I put the scene.my.color into a different place? or do i need a more complex way to do this?
- realflow100
- Posts: 3
- Joined: Wed Dec 16, 2015 12:55 pm
Re: Scene.my.Color = Scene.my.Color problems.
in console:
scene.my.color = [1,1,1,1]
in switch object
onHitByLaser = (e) => {scene.my.color = [0,0,0,1]}
in target object
color = {scene.my.color}
scene.my.color = [1,1,1,1]
in switch object
onHitByLaser = (e) => {scene.my.color = [0,0,0,1]}
in target object
color = {scene.my.color}
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Scene.my.Color = Scene.my.Color problems.
2 possibilitys:
Remote var connection:
Scene.my.var = e.this.color in object 1
e.this.color = scene.my.var in object 2
2nd possibility: Object instance:
target = entitybygeomid(<the geom id of the second object>) in object 1
target.color = [x,y,z,a] in object 1 too
Remote var connection:
Scene.my.var = e.this.color in object 1
e.this.color = scene.my.var in object 2
2nd possibility: Object instance:
target = entitybygeomid(<the geom id of the second object>) in object 1
target.color = [x,y,z,a] in object 1 too
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: Scene.my.Color = Scene.my.Color problems.
Kilinich wrote:in console:
scene.my.color = [1,1,1,1]
in switch object
onHitByLaser = (e) => {scene.my.color = [0,0,0,1]}
in target object
color = {scene.my.color}
Omg thanks this works PERFECTLY! Such a simple solution!!! Omg!
I copied the color of the object that I wanted the color to be into the part after scene.my.color=[copy and pasted color] and did it in the other objects that i wanted the color to be set to.
Now I'm one step further to creating an LCD display!
- realflow100
- Posts: 3
- Joined: Wed Dec 16, 2015 12:55 pm
Re: Scene.my.Color = Scene.my.Color problems.
If you need to color about 32 pixels seperatly, I would recommend using some wayaround so you dont store 32 scene my variables for some color. You could for example create 1 single variable with an array (the vars with []), and in that array are 32 numbers, ranging from 1-4. Each number represents a color state, and then you just need to make the corresponding pixel react to that number, for example using another array as a scene.my.variable, called something like scene.my.colors, and it contains an array containing even more arrays, and each of THESE arrays contains the color, like this:
Scene.my.States = [1,1,3,4,2,2,3,4,4,4,2,1,1,1,2,1,3,3,3,3,2,4,1,2,2,1,4,4,3,2,2,4] - 32 numbers representing one of four colors each
Scene.My.Colors = [[0,0,0,1],[1,0,0,1],[0,1,0,1],[0,0,1,1]] - an array containing the color values for black, red, green and blue
Then it's very simple: Every pixel has this code:
e.this.color = scene.my.Colors(scene.my.states(<Number of the pixel>-1) - 1)
What it would do: The pixel takes it's corresponding value from the states scene, substracts 1 since arrays start at 0, and then inserts that number it read into scene.my.Colors, again substracting 1 because of array, and whatever value it find's there will be it's color. If we take the above example values, it could look like this:
e.this.color = Scene.My.Colors(Scene.My.States(6-1)-1)
the sixth value of scene.my.states is 2, and the color assigned to 2 is red, so pixel #6 would turn red
Scene.my.States = [1,1,3,4,2,2,3,4,4,4,2,1,1,1,2,1,3,3,3,3,2,4,1,2,2,1,4,4,3,2,2,4] - 32 numbers representing one of four colors each
Scene.My.Colors = [[0,0,0,1],[1,0,0,1],[0,1,0,1],[0,0,1,1]] - an array containing the color values for black, red, green and blue
Then it's very simple: Every pixel has this code:
e.this.color = scene.my.Colors(scene.my.states(<Number of the pixel>-1) - 1)
What it would do: The pixel takes it's corresponding value from the states scene, substracts 1 since arrays start at 0, and then inserts that number it read into scene.my.Colors, again substracting 1 because of array, and whatever value it find's there will be it's color. If we take the above example values, it could look like this:
e.this.color = Scene.My.Colors(Scene.My.States(6-1)-1)
the sixth value of scene.my.states is 2, and the color assigned to 2 is red, so pixel #6 would turn red
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: Scene.my.Color = Scene.my.Color problems.
thanks. might help to reduce the lag when I have a few hundred objects moving around and colliding with others.
hopefully i find a way to sync all of the pixels timings
hopefully i find a way to sync all of the pixels timings
- realflow100
- Posts: 3
- Joined: Wed Dec 16, 2015 12:55 pm
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



