New Script Command Request


@DJ and team.

I give a small request that I hope you would consider adding to EZ-Script.

Would it be possible to add a new script command for servostop()? I'm not talking about the one the one that already exists for Modified Servos, but for standard ones (more like a stopservo() or possitionstop() command). The idea is to add this for things like controllers and joysticks.

E.g, you have a servo which has a centre possition of 90, and a set max possition of say 160, and a set speed of 2. When a button is pressed on a controller the servo starts to move from 90 towards 160, but if you release the button the servo stops in its current possition and stays there. Press the button again and it continued to travel towards 160, or back to 90 by pressing another button.

I'm aware that there are ways to write a script for this, but I've had a lot of trouble with it so far, and having a simple script command in the script menu would make things so much easier. Would it be something that you would consider adding? And if there is a command to do just this, then I apologise in advance and would appreciate someone informing me of what script command to use.



you can use the functions


ServoUp (servoPort, count)
ServoDown (servoPort, count)

and loop them while the joystick button is pressed and set a max value for that specific servo to stop at.


#set speed of servo
#increases servo position in increments of 2 degrees

#and the reverse being, as a separate script

This could be a simple script that you call each time the button is pressed.

I hope i understood you're problem correctly and that this helps Smile



Thanks for your reply. I am currently using servoup() and servodown() commands but don't like having to repeatedly press a button to move through increments. I must admit though that I haven't considered using a loop. I will give it a try a little later. Thanks for the advice. Smile

I still think having a simple command to use to achieve this would be a good idea. Something that could be put in to "when button is released" in the control config. Is it something you would consider adding DJ? Winky


Didn't I provide you with a script which does exactly what you are asking? (Which is pretty much the same method @VGosine posted above).

You shouldn't need to keep pressing a button over and over to make it work. Check out Gwen's B9 movement help topic and the code I provided for her, this runs when button is pressed and stops when released. The project is in my cloud and is public. Use a similar method for your required actions.



yeah, the script example you supplied is what I'm currently using which is good, but I do have to keep pressing the button to move each increment I set (I have them set at 10). So if I want the servo to move, to say possition 120, I have to press the button lots of times, and if I change the increment value to 20 or more and want the servo to stop at possition 105, it will over shoot that possition.

I just thought it would be a lot easier to have a specified script command (like servo(), servospeed() ect) to simply stop a servos travel that could be inserted in to the "when button is released" configuration. Kind of like a momentary switch action.


Have had a look through Gwens thread and the cloud project. Unfortunately, looking through the code I'm not sure what I'm looking for. Just to be clear, I am talking about joystick/pad "buttons", not the D pad.


Use some if commands then... set your servo increment to 20... Then use an if statement to set it at 105 if it should over shoot...


If (GetServo(D0) >105
servo(D0,105) #set servo D0 at 105


Thanks Richard. I'll try this a bit later. Where do I put this script, in the "when button is pressed" or "when button is released" script editor? (I asume its the first one).


If you want everything to stop when the button is released you need that script to be empty and only have the commands, loops and ifs in the on button down part.

While the button is pushed the script will loop.

You may find it easier to write the scripts in script manager and use ControlCommand() with ScriptStart and ScriptStop on the on button down and on button up. This way, when the button is pressed and held the script runs and loops etc. as soon as the button is release the script is stopped by ControlCommand().

Check the version history of the project I made for Gwen, originally the movement was assigned to buttons not joysticks as I had a brain fart and totally forgot the joystick controls the Movement Panel.


@steve... you mentioned that you need to push the button too many times unless you set the increment to 20... My example code would have to go in the button push script... It checks to see if you pressed the button too many times and have exceeded the 105 ceiling... it then sets the servo to back 105 until you press the down button (or whatever direction you are going)...

@Rich's solution to write separate scripts outside of the button push scripts and to use ControlCommand() to start and stop them is a better method... It keeps code shorter so you don have one massive complicated script that becomes difficult to read and debug....