Create machines
A Creative Motor and a Rotation Speed Controller set by program, gauges read directly, a Sequenced Gearshift that turns on demand, and a Sticker.
Some of Create's blocks do more for a computer than turn. A Creative Motor and a Rotation Speed Controller take a new speed, the Speedometer and the Stressometer hand over their readings, a Sequenced Gearshift turns by the angle the program asks for, and a Sticker comes out or goes back in. Each one has a peripheral type of its own:
| Block (in game) | peripheral type | what a program does with it |
|---|---|---|
| Creative Motor | creative_motor | reads and sets the speed it makes |
| Rotation Speed Controller | speed_controller | reads and sets the speed of its output |
| Speedometer | speedometer | reads the speed of its shaft |
| Stressometer | stressometer | reads the stress and the capacity of its network |
| Sequenced Gearshift | sequenced_gearshift | turns its output by an angle, or moves a piston by a number of blocks |
| Sticker | sticker | makes it come out, go back in, and checks what it holds |
local motor = peripheral.find("creative_motor")
motor.set_generated_speed(128)motor.generated_speed() | The speed the Creative Motor makes: the number on its value panel. |
motor.set_generated_speed(rpm) | Sets the speed the motor makes, as scrolling on its value panel does. |
ctrl.target_speed() | The speed the Rotation Speed Controller gives the large cogwheel on top of it: the number on its value panel. |
ctrl.set_target_speed(rpm) | Sets the speed of the controller's output, as scrolling on its value panel does. |
speedo.speed() | How fast the gauge's shaft turns: what its needle shows. |
gauge.stress() | The stress used on the gauge's network, as its dial shows it. |
gauge.capacity() | The capacity of the gauge's network: what its motors, water wheels and engines give. Cheap too. |
gear.rotate(degrees [, speed]) | Turns the output of the gearshift by that angle, then stops it: Create's "Turn by angle" instruction. |
gear.move(blocks [, speed]) | Moves a Mechanical Piston, a Rope Pulley or a Gantry Carriage driven by the gearshift by that many blocks: Create's "Turn to move Piston/Pulley/Gantry" instruction. |
gear.running() | Whether the gearshift is busy. |
sticker.extended() | Whether the Sticker is out. |
sticker.attached() | Whether the Sticker holds something: it is out, and the block in front of it is one it can stick to. Air or water in front of it read false. |
sticker.extend() | Makes the Sticker come out: from now on, the block in front of it moves with it. |
sticker.retract() | Makes the Sticker go back in: the block it held is let go. |
sticker.toggle() | Out if it was in, in if it was out, like a redstone pulse. |
Setting up
Reaching them. Like every device, a block against the computer is called by its side ("left", "back"...), and a block against a Data Cable (Minicomputer and newer) gets a name such as sequenced_gearshift@120,64,-35. The easiest is peripheral.find with the type of the table. See Peripherals.
They turn, too. Every block of this page except the Sticker is also a Create kinetic block, with speed(), stress(), capacity() and overstressed() on top of its own methods. Its type, and its name on a cable, stays the one of the table.
Changes at the end of the tick. A new speed for a motor or a controller, or a new move for a gearshift, rebuilds Create's kinetic network. The computer does not do it on the spot: it notes the request and applies it at the end of the program's tick, once per block, with the last value asked. A loop that calls set_generated_speed a thousand times in one tick costs the world a single update. Two things follow:
- reading right after, in the same tick, still gives the old value:
sleep(0.05)waits one tick; - two moves asked of a gearshift in the same tick do not add up: only the last one runs.
The Sticker is the exception: it moves at once.
When it fails. When the block is broken or replaced, its methods stop the program with creative motor removed (speed controller removed, sequenced gearshift removed...). When its chunk is not loaded: peripheral is not loaded.
Rotation
motor.generated_speed()
The speed the Creative Motor makes: the number on its value panel.
- number
- the speed set on the motor, in RPM, negative for the other way
It is the setting, not a measure. To know how fast the shaft really turns (0 while the network is overstressed), ask motor.speed(), the kinetic.speed() every kinetic block has.
local motor = peripheral.wrap("back")
print("motor set to " .. motor.generated_speed() .. " RPM")See also creative_motor.set_generated_speed() kinetic.speed()
motor.set_generated_speed(rpm)
Sets the speed the motor makes, as scrolling on its value panel does.
rpmnumber- the new speed, a whole number of RPM, negative to turn the other way
0 stops it, a negative speed reverses it. Values beyond -256 and 256 are brought back to them. The new speed stays in the motor after the program ends. It is applied at the end of the tick. A number with decimals stops the program with bad argument #1 to 'set_generated_speed' (number has no integer representation): round it first with math.round.
A test bench that runs a new machine faster and faster, two seconds per step, then stops it:
local motor = peripheral.find("creative_motor")
for rpm = 16, 256, 16 do
motor.set_generated_speed(rpm)
print(rpm .. " RPM")
sleep(2)
end
motor.set_generated_speed(0)See also creative_motor.generated_speed()
ctrl.target_speed()
The speed the Rotation Speed Controller gives the large cogwheel on top of it: the number on its value panel.
- number
- the speed the controller aims for, in RPM, negative for the other way
The cogwheel turns at that speed only while the controller's input shaft turns. ctrl.speed() (from Create kinetic blocks) reads the input, not the cogwheel.
local ctrl = peripheral.wrap("right")
print("target: " .. ctrl.target_speed() .. " RPM")See also speed_controller.set_target_speed()
ctrl.set_target_speed(rpm)
Sets the speed of the controller's output, as scrolling on its value panel does.
rpmnumber- the new target, a whole number of RPM from -256 to 256, negative to turn the other way
The rules are those of the motor: kept between -256 and 256, whole numbers only, applied at the end of the tick, and kept after the program ends. The older kinetic.set_speed() does the same on a controller and still works.
An Analog Lever on the left sets the speed of the line, from 0 to 128 RPM:
local ctrl = peripheral.wrap("right")
while true do
local rpm = math.round(rs.get("left") / 15 * 128)
if rpm ~= ctrl.target_speed() then
ctrl.set_target_speed(rpm)
end
sleep(0.5)
endSee also speed_controller.target_speed() kinetic.set_speed()
Gauges
A Speedometer and a Stressometer show their readings on a dial; the computer gets the same numbers.
speedo.speed()
How fast the gauge's shaft turns: what its needle shows.
- number
- the speed of the shaft that runs through the gauge, in RPM, negative for the other way
local speedo = peripheral.find("speedometer")
rs.set("top", math.abs(speedo.speed()) < 32) -- a lamp when the line runs slowgauge.stress()
The stress used on the gauge's network, as its dial shows it.
- number
- the stress the machines of the network draw, in SU
It gives the same number as kinetic.stress(), but much cheaper: the gauge already knows it, so the call does not walk through the network and costs no extra instructions, however big the factory. On a gauge that is on no network, it reads 0.
See also stressometer.capacity() kinetic.stress()
gauge.capacity()
The capacity of the gauge's network: what its motors, water wheels and engines give. Cheap too.
- number
- the stress the sources of the network can give, in SU
local gauge = peripheral.find("stressometer")
local cap = gauge.capacity()
if cap > 0 then
print(string.format("load %d %%", math.floor(gauge.stress() / cap * 100)))
else
print("nothing drives this network")
endSee also stressometer.stress() kinetic.capacity()
Sequenced Gearshift
In Create, a Sequenced Gearshift runs a list of instructions set in its screen each time it gets a redstone pulse (Redstone and Create links). A program gives it one move at a time instead, with the angle or the distance it wants, then waits for the end.
rotate and move replace the list of instructions of the gearshift with a single turn (or move) followed by an end. Whatever you had set in its screen is erased, for good. The new instruction stays in the gearshift: a redstone pulse on it later runs that last move again.
Between two moves the output stands still, like a gearshift at the end of its list. The input shaft must turn: the gearshift passes its rotation to the output just long enough to cover the angle or the distance.
gear.rotate(degrees [, speed])
Turns the output of the gearshift by that angle, then stops it: Create's "Turn by angle" instruction.
degreesnumber- how far the output turns, in degrees, a whole number (its sign is ignored)
speednumber optional1the speed of the input (the default),2twice as fast,-1and-2the same the other way
A Mechanical Bearing on the output turns its structure by exactly that much: a door that swings 90 degrees, a turntable that moves by one station. The direction comes from speed alone: -90 is the same as 90. Angles above 100000 are brought back to it. The move starts at the end of the tick.
local gear = peripheral.find("sequenced_gearshift")
gear.rotate(90) -- a quarter turnAny other speed stops the program with bad argument #2 to 'rotate' (speed multiplier 1, 2, -1 or -2), and an angle with decimals with number has no integer representation.
See also sequenced_gearshift.move() sequenced_gearshift.running()
gear.move(blocks [, speed])
Moves a Mechanical Piston, a Rope Pulley or a Gantry Carriage driven by the gearshift by that many blocks: Create's "Turn to move Piston/Pulley/Gantry" instruction.
blocksnumber- how many blocks the piston, pulley or gantry moves, a whole number (its sign is ignored)
speednumber optional1,2,-1or-2, as forrotate
Which way it goes depends on speed and on how the machine is built: try 1 and -1 once. Like rotate, it replaces the screen's instructions and starts at the end of the tick.
local gear = peripheral.find("sequenced_gearshift")
gear.move(4) -- the piston pushes the wall out by 4 blocks
sleep(10)
gear.move(4, -1) -- and pulls it backSee also sequenced_gearshift.rotate() sequenced_gearshift.running()
gear.running()
Whether the gearshift is busy.
- boolean
truewhile the gearshift is running a move,falseonce it is idle
A move asked in this tick only starts at its end, so running() right after rotate still says false. Wait a tick before you ask:
local gear = peripheral.find("sequenced_gearshift")
gear.rotate(180)
sleep(0.05) -- the move starts at the end of the tick
while gear.running() do
sleep(0.1)
end
print("half a turn done")Sticker
A Sticker glues the block in front of it while it is out. On a moving contraption (a piston, a bearing, a gantry), that block then travels with it, and stays behind once the Sticker is back in. A redstone pulse toggles it in Create; a program uses the methods below, which act at once, not at the end of the tick.
sticker.extended()
Whether the Sticker is out.
- boolean
truewhen the Sticker is out
local sticker = peripheral.find("sticker")
print(sticker.extended())See also sticker.attached()
sticker.attached()
Whether the Sticker holds something: it is out, and the block in front of it is one it can stick to. Air or water in front of it read false.
- boolean
truewhen the Sticker is out and stuck to a block
local sticker = peripheral.find("sticker")
sticker.extend()
if not sticker.attached() then
print("nothing to pick up")
endsticker.extend()
Makes the Sticker come out: from now on, the block in front of it moves with it.
- boolean
truewhen the Sticker came out,falsewhen it already was out
See also sticker.retract() sticker.toggle()
sticker.retract()
Makes the Sticker go back in: the block it held is let go.
- boolean
truewhen the Sticker went back in,falsewhen it already was in
See also sticker.extend() sticker.toggle()
sticker.toggle()
Out if it was in, in if it was out, like a redstone pulse.
- boolean
truewhen the Sticker moved
Examples
A line that eases off before overstress
A Rotation Speed Controller drives a row of Mechanical Presses, and a Stressometer sits on the same network. When the load passes 90 %, the program slows the line by 16 RPM; below 70 %, it speeds it back up, up to 128 RPM. The presses never stop on an overstress, they just run a little slower when the network is busy.
local ctrl = peripheral.find("speed_controller")
local gauge = peripheral.find("stressometer")
local MAX = 128
local rpm = MAX
ctrl.set_target_speed(rpm)
while true do
local cap = gauge.capacity()
if cap > 0 then
local load = gauge.stress() / cap
if load > 0.9 and rpm > 16 then
rpm = rpm - 16
elseif load < 0.7 and rpm < MAX then
rpm = rpm + 16
end
ctrl.set_target_speed(rpm)
print(string.format("load %d %%, presses at %d RPM", math.floor(load * 100), rpm))
end
sleep(2)
endThe Overstress guard recipe protects a whole factory with the generic Create kinetic blocks methods.
Fetching a block with a Sticker
A Sticky Mechanical Piston carries a Sticker on its head and is driven by a Sequenced Gearshift. A Data Cable runs along the piston's path, so that the computer reaches the Sticker wherever it stops (its name changes with its position, so the program finds it again each time). The piston goes out 3 blocks, the Sticker grabs the block it meets, and the piston brings it back.
local gear = peripheral.find("sequenced_gearshift")
local function wait_for_piston()
sleep(0.05)
while gear.running() do
sleep(0.1)
end
sleep(0.5) -- the piston sets its blocks down
end
gear.move(3)
wait_for_piston()
local sticker = peripheral.find("sticker")
sticker.extend()
if sticker.attached() then
gear.move(3, -1)
wait_for_piston()
peripheral.find("sticker").retract()
print("block delivered")
else
sticker.retract()
print("nothing to fetch")
endwait_for_piston can use gear because gear is a local of the chunk, not of another function.