This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Pretender6's profile picture

Wireless Redstone Question

Started by Pretender6, 13 July 2013 - 10:50 AM
Pretender6 #1
Posted 13 July 2013 - 12:50 PM
Hi, I'm using Wireless redstone for awhile now, first the classic block version and later with Chicken Bones version, and developed something as a switchboard with backwards compatability in mind, like using a row of levers next to transmitters is considered basic, and using a computer, ( Redpower2 Control for now) to activate the Transmitters

I've been using Wireless Recievers and Logic AND gates and Toggle Gates for the Reciever part, but results in a very large footprint of 3x4x3, which sometimes is a bit costly if you wants to create prison cell or something compact

My Reciever setup toggles on when freqs are active on for example 41 / 32 / 23 / 14 / 90 / 4 / 1 which translates into 1000 / 200 / 30 / 4 North Door ON and thus Opening North Door # 1234

Have read it somewhere that some servers use pre assigned freq for Major players, with this system you could create atleast 200.000 new freq by using around 98/100 freqs, as the "state" is determed at reciever side, the signals should not be transmitting more that a couple of seconds

If possible i'd like some simliair code that helps me along programming a turtle or computer with REther Upgrade to scan for its Preset Freqs, When they are all active, the turtle/computer either emits a redstone itself and stays on or places a redstone torch, and when the OFF signal is given vice versa
Lyqyd #2
Posted 15 July 2013 - 12:37 PM
Split into new topic.
Pretender6 #3
Posted 01 August 2013 - 04:45 PM
Can somebody check this code?

I'd like to check for 7 different frequencies and only then emitting an redstone signal or stop emitting an redstone signal

m = peripheral.wrap("right")

local f1
local f2
local f3
local f4
local f5
local f6
local f7
local f8
local fc

f1 = 0
f2 = 0
f3 = 0
f4 = 0
f5 = 0
f6 = 0
f7 = 0
f8 = 0
fc = 100

function Check1()
m = peripheral.wrap("right")
  m.setFreq = 42
  sleep(1)
	if m.get() then
	f1 = 1	
  else
	f1 = 0
  end
	print(f1)  
end  

function Check2()
m = peripheral.wrap("right")
  m.setFreq = 32
  if m.get() then
	f2 = 1	
  else
	f2 = 0
  end
	print(f2)  
end  
function Check3()
m = peripheral.wrap("right")
  m.setFreq = 23
  if m.get() then
	f3 = 1	
  else
	f3 = 0
  end
	print(f3)  
end  
function Check4()
m = peripheral.wrap("right")
  m.setFreq = 14
  if m.get() then
	f4 = 1	
  else
	f4 = 0
  end
	print(f4)  
end  
function Check5()
m = peripheral.wrap("right")
  m.setFreq = 3
  if m.get() then
	f5 = 1	
  else
	f5 = 0
  end
	print(f5)  
end  
function Check6()
m = peripheral.wrap("right")
  m.setFreq = 7
  if m.get() then
	f6 = 1	
  else
	f6 = 0
  end
	print(f6)  
end  
function Check7()
m = peripheral.wrap("right")
  m.setFreq = 1
  if m.get() then
	f7 = 1	
  else
	f7 = 0
  end
	print(f1)  
end  


function Check8()
m = peripheral.wrap("right")

f8 = f1+f2+f3+f4+f5+f6+f7+fc
print(f8)

end

function Clear()
	f1 = 0
	f8 = 0
end

function TurnOn()
  redstone.setOutput("left", true)
end

function TurnOff()
  redstone.setOutput("left", false)
end

	Check1()  
	Check2()  
	Check3()  
	Check4()  
	Check5()  
	Check6()  
	Check7()  
	Check8()
	Clear()
Edited by
campicus #4
Posted 01 August 2013 - 09:03 PM
Just a few housekeeping things.

Use [*code] <yourcodehere> to post code (make sure it is formatted correctly)
If it is long code definitely use [*spoiler] <yourcodehere> or preferably pastebin.com

I don't think people are keen to "check this code". You check it and if you have an issue come to the forum with that :)/>

EDIT: had to put "*" in so it showed the code, don't put those in
Bubba #5
Posted 02 August 2013 - 12:06 AM
Although I am unfamiliar with the REther upgrade for turtles (MiscPeripherals?), I may be able to help you out with the logic behind this question.

So if I am reading correctly, you want to wait until all frequencies of this REther upgrade are active, and at that point output a redstone signal. If that's it, this is actually quite a bit easier than the code that you posted.

Our first step would be to somehow get a list of all the frequencies we want to check. Lua makes this easy for us through the use of tables. Tables are just a collection of data, so it fits perfectly for this.

Creating a table with all of the channels we want to listen on is easy:

local frequencies = {
  42, 32, 23, 14, 3, 7, 1
}

We can access each of these items by using a for loop:

for index=1, #frequencies do
  local theFrequency = frequencies[index]
end

The # character is getting the length of the frequencies table, allowing us to do a loop from the first index to the last index of frequencies.

Next, we'll want to check if the specific frequency is on. For this we can use a simple boolean.

local m = peripheral.wrap("right")
local shouldOutput = true
for index=1, #frequencies do
  m.setFreq(frequencies[index])
  if not m.get() then
    shouldOutput = false
  end
end

rs.setOutput("back", shouldOutput)

As you can see, this simplifies things by quite a bit.