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

Im in too Deep! Wireless client(s), Wireless input/ bundled output server

Started by Flass Maximus, 08 October 2012 - 08:49 AM
Flass Maximus #1
Posted 08 October 2012 - 10:49 AM
Hi there Forum,.

I've Been working on a "central force-field and power control" designed to be encapsulated by internally generated force-fields.
this promptly brought the problem of "how do it turn it off?" to my attention seeing as the core, the projector and about 30m EU of power storage all reside INSIDE the shield with no holes or gaps save for the in/out EU cable.

I've spent about two hours now scouring the forums looking for a walk-through on the subject of wireless input to bundled output, I Did find some parts, but they were somewhat disjointed to someone with VERY little lua knowledge and experience such as myself.

I Kindly Request an workable example piece from anyone who has done this sort of project before or know how and have ten minutes spare while you wait for the train or something ;)/>/>.. Some side notes on HOW it works would also be greatly appreciated, as I would like to learn how to expand this code myself as my project becomes more complex.

I currently have Three outputs, i'm hoping to be able to input client side commands to toggle the state of each.


I Promise Screenshots if i can get it to work :D/>/>
KaoS #2
Posted 08 October 2012 - 11:04 AM
CLIENT
Spoiler

local modemside='right'
local wireside='back'
rednet.open(modemside)
local function listenFor('keyword')
while true do
  local input=rednet.receive()
  input[2]==textutils.unserialize(input[2])
  if type(input[2])=='table' and input[2][1]==keyword then
   return unpack(input)
  end
end
end
while true do
local input={listenfor('forceField')}
rs.setBundledOutput(wireside,input[2][2])
end

Controller:
Spoiler

local modemside='right'
rednet.open(modemside)
while true do
term.clear()
term.setCursorPos(1,1)
print('Enter colour')
write('col: ')
local colour=read()
if colors[colour] then
  rednet.broadcast(textutils.serialize('forceField',colors[colour]))
else
  print('invalid colour')
  sleep(2)
end
end

EDIT: basically you start up the client first with a modem on the right and bundled cables out the back, you set up the controller with just a modem on the right. when you start up the controller it asks you for a colour, you enter the colour and that colour wire will turn on at the client (only that colour, the other ones will turn off. I can set it to toggle if you like)

if you want a full list of colours use the script

for k,v in pairs(colors) do
  if type(v)=='number' then
    print(k)
  end
end
Pharap #3
Posted 08 October 2012 - 11:11 AM
Have a computer to send wireless commands, program a second computer to pick up those commands and output to bundled cable accordingly.
Flass Maximus #4
Posted 08 October 2012 - 03:59 PM
This makes sense to me.
though in lieu of the rednet.broadcast call, seeing as i hope to have multiple wireless control systems within range, could i use a rednet.send call?
as in


if colors[colour] then
rednet.send(13, textutils.serialize('forceField',colors[colour]))

assuming that computer 13 is the client


:D/>/> the server i play on seems to have crashed and its nearly 2AM
however tomorrow i intend to implement this and some other similar wireless bits, hoping to use a turtle to unlock forcefield doors

will post with updates / screenshots tomorrow morning.
NIN3 #5
Posted 08 October 2012 - 04:39 PM
Dont forget, you can always use wirless chicken bones. Its a mightly big easyer to set up, but lacks the password protection….
KaoS #6
Posted 10 October 2012 - 10:05 AM
rednet send would change nothing :P/>/>