I am coding our catapult to draw back until it hits a limit switch. It then rumbles the controller and prints “Ready” on the controller screen to indicate the catapult is ready to load. When the Y button is pressed the catapult draws back a little more until it slips and fires. It then begins drawing back again.
The code works, however I can only fire the catapult 3 times before it throws an error that wont let me fire anymore. “no event resources available”. below is the snippet of code and the error it throws. Any help would be appreciated as I cannot figure out why it won’t fire more than 3 times.
Code:
#pressing B manually draws the catapult back. normally used at the start of driver control
if controller1.buttonB.pressing():
catapultMotor.spin(FORWARD,50,PERCENT)
controller1.screen.set_cursor(1,4)
controller1.screen.clear_row(1)
controller1.screen.print('Manual') #just printing a status on the controller screen if needed
limit_switch_b.pressed(ready) #calls the "ready" function when the limit switch is pressed
#fires the catapult when Y button pressed, then begins drawing it back again
if controller1.buttonY.pressing() and load == 1: #load variable to make sure the catapult is fully drawn back before allowing someone to fire
catapultMotor.spin(FORWARD,100,PERCENT)
limit_switch_b.released(pull) #when the gear slips and the catapult launches it releases the limit switch and calls the "pull" function
wait(5, MSEC)
# called when catapult launches and releases limit switch
def pull():
global load #makes the load variable in the function a global variable
load = 0 #indicates that the catapult is not ready, prevents driver from firing again
catapultMotor.spin(FORWARD,50,PERCENT) #draws back catapult
limit_switch_b.pressed(ready) #when the catapult presses down the limit switch, calls the "ready" function
# called when the catapult presses the limit switch and is ready to launch
def ready():
catapultMotor.stop()
controller1.screen.set_cursor(1,4)
controller1.screen.clear_row(1)
controller1.screen.print('Ready')#prints on controller screen incase its needed
controller1.rumble("-")#tells driver the catapult is ready to load without making them look down at the screen
global load
load = 1 #changes load variable to unlock firing controls
Error:
Unhandled exception in thread started by <function user_control at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 160, in user_control
RuntimeError: no event resources available
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 166, in user_control
AttributeError: no such attribute
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 166, in user_control
AttributeError: no such attribute
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 165, in user_control
AttributeError: no such attribute
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 165, in user_control
AttributeError: no such attribute
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 165, in user_control
AttributeError: no such attribute
Unhandled exception in thread started by <function user_control at 0x385fe40>
Traceback (most recent call last):
File “userpy”, line 172, in user_control
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
UnUnhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pullUnhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pullUnhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pullUnhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
Unhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, inhandled exception in event started by <function pull at 0x385fe50>
Traceback (most recent call last):
File “userpy”, line 183, in pull
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
Runtime
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
RuntimeError: no event resources available
Error: no event resources available