1 from operationscore.Behavior import *
2 import math
3
5 """ModifyParam is a powerful class to perform an action on a specified key in the Argument
6 Dictionary of a response. Specify:
7 <ParamType> -- Sensor or Recurse
8 <ParamName> -- The name of the parameter you wish to modify
9 <ParamOp> -- The modification you wish to do. Use {val} to specify the current value of the
10 parameter in question. Special hooks for {x} and {y} also exist to access the x and y
11 locations."""
12
14 paramType = self['ParamType']
15 if paramType == None:
16 paramType = 'Sensor'
17 paramName = self['ParamName']
18 paramOp = str(self['ParamOp'])
19 if paramType == 'Sensor':
20 searchSet = sensorInputs
21 elif paramType == 'Recurse':
22 searchSet = recursiveInputs
23 else:
24 raise Exception('Unknown Param Type')
25 for behaviorInput in searchSet:
26 if paramName in behaviorInput:
27
28 paramOp = paramOp.replace('{val}', 'behaviorInput[paramName]')
29
30 paramOp = paramOp.replace('{y}', "behaviorInput['Location'][1]")
31 paramOp = paramOp.replace('{x}', "behaviorInput['Location'][0]")
32 behaviorInput[paramName] = eval(paramOp)
33 if paramType == 'Sensor':
34 return (searchSet, recursiveInputs)
35 if paramType == 'Recurse':
36 return (sensorInputs, searchSet)
37