Opencomputers: [SOLVED] Bug with multiple Redstone I/O blocks?

Created on 31 Dec 2016  路  5Comments  路  Source: MightyPirates/OpenComputers

Disclaimer:

I am still new to OpenComputers, so this may be an invalid bug report. If it is and it turns out I am just making a coding mistake, I apologize.

Problem:

In any case, there seems to be an issue when trying to use multiple Redstone I/O blocks on the same computer with the same program.

When typing 'Components', I note down the two addresses of the Redstone I/O Blocks (highlighted in yellow):

The code I then use in my basic test program was meant to assign one block to one variable, and the other to another.
When attempting to activate the redstone signal on both of them, it seems that both variables end up referencing only one of the I/O blocks anyway, despite them both being assigned to the correct addresses.

Code:

local component = require("component")
local sides = require("sides")

rs_top = component.redstone
rs_top.address = component.get("488")

rs_bot = component.redstone
rs_bot.address = component.get("f28")

rs_top.setOutput(sides.east, 255)
rs_bot.setOutput(sides.east, 255)

Any help at all would be greatly appreciated on the matter.

Most helpful comment

no, component.redstone returns you proxy of first redstone component. You don't assign anything to address, just use whatever component.proxy returns, like:

local component = require("component")
local sides = require("sides")

rs_top = component.proxy(component.get("488"))
rs_bot = component.proxy(component.get("f28"))

rs_top.setOutput(sides.east, 255)
rs_bot.setOutput(sides.east, 255)

All 5 comments

You should do rs_bot = component.proxy(component.get("f28")), setting address alone does nothing AFAIK.

Thanks for such fast help!

I have tried doing what you suggested, and the result was that neither piston moved (So neither I/O block output a signal)

I also attempted to edit it and make it work by adding .address, but that didn't work either. What happened was that only one piston would respond to both variables, which I tested by turning off the redstone signal with rs_top.

Preview of edited code

Out of curiosity, why component.proxy?

no, component.redstone returns you proxy of first redstone component. You don't assign anything to address, just use whatever component.proxy returns, like:

local component = require("component")
local sides = require("sides")

rs_top = component.proxy(component.get("488"))
rs_bot = component.proxy(component.get("f28"))

rs_top.setOutput(sides.east, 255)
rs_bot.setOutput(sides.east, 255)

That's quite interesting. Color me impressed and this issue solved.

One last question though:

The reason I would assign it to component.redstone before though was because by default, the variables wouldn't have any of the methods required. Usually when there's just _one_ on the system, you use:

local component = require("component")
local sides = require("sides")

rs = component.redstone
rs.setOutput(sides.east, 255)

So, how does it know how to use the methods now?
Does .proxy fetch methods too?

It seems to be able to; it assigned all the methods to it:

Was this page helpful?
0 / 5 - 0 ratings