From ad8ad25072f55413ecfd696eff1e07c1cd08984e Mon Sep 17 00:00:00 2001 From: rcoh Date: Tue, 25 Jan 2011 14:07:05 -0500 Subject: Fancy param modification --- behaviors/ModifyParam.py | 4 ++++ behaviors/XYMove.py | 1 + 2 files changed, 5 insertions(+) (limited to 'behaviors') diff --git a/behaviors/ModifyParam.py b/behaviors/ModifyParam.py index f589e05..6e76d05 100644 --- a/behaviors/ModifyParam.py +++ b/behaviors/ModifyParam.py @@ -1,4 +1,5 @@ from operationscore.Behavior import * +import math import pdb #Class to perform a given operation on some element of an argDict. Designed to be used a recursive hook, but can serve sensor-based functions as well. Specify ParamType (Sensor or Recurse), ParamName, and ParamOp, (a valid python statement with the old value represented as {val}) class ModifyParam(Behavior): @@ -16,6 +17,9 @@ class ModifyParam(Behavior): if paramName in behaviorInput: #TODO: copy -> modify instead of just #copying paramOp = paramOp.replace('{val}', 'behaviorInput[paramName]') #convert the {val} marker to something we can execute + #TODO: move elsewhere + paramOp = paramOp.replace('{y}', "behaviorInput['Location'][1]") + paramOp = paramOp.replace('{x}', "behaviorInput['Location'][0]") behaviorInput[paramName] = eval(paramOp) if paramType == 'Sensor': #return accordingly return (searchSet, recursiveInputs) diff --git a/behaviors/XYMove.py b/behaviors/XYMove.py index 8acbba8..1b99ee1 100644 --- a/behaviors/XYMove.py +++ b/behaviors/XYMove.py @@ -6,6 +6,7 @@ class XYMove(Behavior): for loc in sensor: oploc = dict(loc) self.insertStepIfMissing(oploc) + print oploc['YStep'] oploc['Location'] = Geo.addLocations((oploc['XStep'], oploc['YStep']), oploc['Location']) ret.append(oploc) return (ret, []) -- cgit v1.2.3