aboutsummaryrefslogtreecommitdiff
path: root/behaviors/ColorChangerBehavior.py
diff options
context:
space:
mode:
authorGravatar Dan <dan@rcoh-ubuntu-small.(none)>2011-01-28 10:11:22 -0500
committerGravatar Dan <dan@rcoh-ubuntu-small.(none)>2011-01-28 10:11:22 -0500
commita028c880c8325419a238667e71a7e919b72a4798 (patch)
tree5a07f674fcead141165a5b4fec0143c3e6c60e05 /behaviors/ColorChangerBehavior.py
parentb8bb5e82a2e8802b9adb1258463d4198f974dbd1 (diff)
parent3319a58ecc391f9aac092ade45f9f50dc2af5aa6 (diff)
Merge branch 'fridaydemo' of github.com:rcoh/SmootLight into osc
Diffstat (limited to 'behaviors/ColorChangerBehavior.py')
-rw-r--r--behaviors/ColorChangerBehavior.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/behaviors/ColorChangerBehavior.py b/behaviors/ColorChangerBehavior.py
index 2a8d974..e2f8bd3 100644
--- a/behaviors/ColorChangerBehavior.py
+++ b/behaviors/ColorChangerBehavior.py
@@ -2,12 +2,26 @@ from operationscore.Behavior import *
import util.ColorOps as color
import pdb
class ColorChangerBehavior(Behavior):
+ """ColorChangerBehavior is a behavior for adding colors to responses. If given no arguments, it
+ will generate a random color. If it is given a list of colors [as below] it will pick randomly
+ from them.
+
+ <ColorList>
+ <Color>(255,0,0)</Color>
+ <Color>(30,79,200)</Color>
+ </ColorList>
+
+ ColorList also supports specification of a single color."""
+
def processResponse(self, sensorInputs, recursiveInputs):
ret = []
for sensory in sensorInputs:
- newDict = dict(sensory) #don't run into shallow copy issues
+ newDict = dict(sensory)
if self['ColorList'] != None:
- newDict['Color'] = color.chooseRandomColor(self['ColorList']) #TODO: this doesn't work.
+ if isinstance(self['ColorList'], list):
+ newDict['Color'] = color.chooseRandomColor(self['ColorList']) #Pick randomly
+ else:
+ newDict['Color'] = self['ColorList'] #Unless there is only one
else:
newDict['Color'] = color.randomColor()
ret.append(newDict)