I want to pass a spoken numerical value to a function, but I'm having problems casting that value to an integer. I am only able to pass the string %(number)d to the foo function.
I've tried many different things to cast the spoken value to a number including int, float, and %(n)d.
def foo(slot):
startingPoint = .15
increment = .05
calculation = (slot*increment)
slotNumber = (startingPoint + calculation) - increment
return "(0.1, {}), left".format(slotNumber)
class CodeMappings(MappingRule):
mapping = {
'slot <number>': foo('%(number)d'),
'slot 1': Mouse("(0.1, 0.15), left"),
'slot 2': Mouse("(0.1, 0.2), left"),
'slot 3': Mouse("(0.1, 0.25), left"),
'Slot 4': Mouse("(0.1, 0.30), left"),
'Slot 5': Mouse("(0.1, 0.35), left"),
'Slot 6': Mouse("(0.1, 0.40), left"),
'Slot 7': Mouse("(0.1, 0.45), left"),
'Slot 8': Mouse("(0.1, 0.50), left"),
}
extras=[
Integer('number', 1, 9999),
]
I want to be able to send a spoken numeric value to the foo method and have it return the appropriate mouse coordination. Essentially I should be able to write one method to replace the equivalent of slot 1 - slot 8.