mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 09:18:05 -04:00
simplified redstone driver (just using the message source as the redstone input/output provider)
This commit is contained in:
parent
1454512860
commit
c556f4044e
@ -1,12 +1,9 @@
|
||||
driver.redstone = {}
|
||||
|
||||
-- Save this before there's a chance it gets changed by a user.
|
||||
local owner = os.address()
|
||||
|
||||
function driver.redstone.analogInput(card, side)
|
||||
checkArg(1, card, "string")
|
||||
checkArg(2, side, "number")
|
||||
return send(card, "redstone.input", owner, side)
|
||||
return send(card, "redstone.input", side)
|
||||
end
|
||||
|
||||
function driver.redstone.analogOutput(card, side, value)
|
||||
@ -14,9 +11,9 @@ function driver.redstone.analogOutput(card, side, value)
|
||||
checkArg(2, side, "number")
|
||||
checkArg(3, value, "number", "nil")
|
||||
if value then
|
||||
return send(card, "redstone.output=", owner, side, value)
|
||||
return send(card, "redstone.output=", side, value)
|
||||
else
|
||||
return send(card, "redstone.output", owner, side)
|
||||
return send(card, "redstone.output", side)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -12,14 +12,14 @@ class RedstoneCard extends Component {
|
||||
|
||||
override def receive(message: Message) = super.receive(message).orElse {
|
||||
message.data match {
|
||||
case Array(target: Array[Byte], side: Double) if message.name == "redstone.input" =>
|
||||
network.get.sendToAddress(this, new String(target, "UTF-8"),
|
||||
case Array(side: Double) if message.name == "redstone.input" =>
|
||||
network.get.sendToAddress(this, message.source.address.get,
|
||||
"redstone.input", ForgeDirection.getOrientation(side.toInt))
|
||||
case Array(target: Array[Byte], side: Double) if message.name == "redstone.output" =>
|
||||
network.get.sendToAddress(this, new String(target, "UTF-8"),
|
||||
case Array(side: Double) if message.name == "redstone.output" =>
|
||||
network.get.sendToAddress(this, message.source.address.get,
|
||||
"redstone.output", ForgeDirection.getOrientation(side.toInt))
|
||||
case Array(target: Array[Byte], side: Double, value: Double) if message.name == "redstone.output=" =>
|
||||
network.get.sendToAddress(this, new String(target, "UTF-8"),
|
||||
case Array(side: Double, value: Double) if message.name == "redstone.output=" =>
|
||||
network.get.sendToAddress(this, message.source.address.get,
|
||||
"redstone.output=", ForgeDirection.getOrientation(side.toInt), value.toInt)
|
||||
case _ => None // Ignore.
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user