Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //To use this script: Set the blocknames below. Then when you call the "Run" script, pass in an argument.
- //The two argument types are:
- // - Decimal Number: Any number value to adjust the block speed by. ex: 0.01, -1.53, 2.12, -0.02
- // - STOP: If you pass the "STOP" argument into the script, it will set the velocity to 0.
- //Then whenever you run the script, it will adjust the block's velocity by the amount in the argument, or stop it
- //if the argument was STOP.
- //Config stuff:
- //Set the name of the block. Make sure to set the correct name to the correct block type.
- //Leave the other block types you are not using blank.
- //NOTE: I did not program in any failure prevention, so if it cant find the block, it will just crash the script.
- String rotorName = "";
- String hingeName = "";
- String pistonName = "";
- //Just some program stuff
- IMyMotorStator rotor;
- IMyPistonBase piston;
- IMyMotorAdvancedStator hinge;
- float currentVelocity;
- public Program()
- {
- //Set current velocity to 0 at the start
- currentVelocity = 0f;
- }
- public void Main(string argument, UpdateType updateSource)
- {
- //Change current velocity
- if (argument.Equals("STOP"))
- {
- currentVelocity = 0f;
- }
- else
- {
- currentVelocity += float.Parse(argument);
- }
- Echo("New Velocity = " + currentVelocity);
- //Get block and set to velocity
- if (!rotorName.Equals(""))
- {
- rotor = GridTerminalSystem.GetBlockWithName(rotorName) as IMyMotorStator;
- rotor.SetValueFloat("Velocity", currentVelocity);
- } else if (!hingeName.Equals(""))
- {
- hinge = GridTerminalSystem.GetBlockWithName(hingeName) as IMyMotorAdvancedStator;
- hinge.SetValueFloat("Velocity", currentVelocity);
- } else if (!pistonName.Equals(""))
- {
- piston = GridTerminalSystem.GetBlockWithName(pistonName) as IMyPistonBase;
- piston.SetValueFloat("Velocity", currentVelocity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement