Jump to content




using rednet messages to execute commands


4 replies to this topic

#1 awesomekaj

  • New Members
  • 1 posts

Posted 01 April 2012 - 05:00 PM

I'm trying to make a nuclear powerplant (using industrialcraft) with a main console, this console is going to have a gui and options to control reactor cooling and doors, shutters, power distribution etc. Of course one redstone output won't be enough to make this work. So I decided to make it transmit messages via wireless modems and rednet to other pc's that then execute commands, in this case mostly activating redstone currents. Being new to coding in general, how could i do this?
(my current version of minecraft is 1.1 because i'm using tekkit)

#2 ComputerCraftFan11

  • Members
  • 771 posts
  • LocationHawaii

Posted 01 April 2012 - 08:10 PM

View Postawesomekaj, on 01 April 2012 - 05:00 PM, said:

I'm trying to make a nuclear powerplant (using industrialcraft) with a main console, this console is going to have a gui and options to control reactor cooling and doors, shutters, power distribution etc. Of course one redstone output won't be enough to make this work. So I decided to make it transmit messages via wireless modems and rednet to other pc's that then execute commands, in this case mostly activating redstone currents. Being new to coding in general, how could i do this?
(my current version of minecraft is 1.1 because i'm using tekkit)


Sender:
rednet.open("side of modem")
rednet.send(*INSERT ID OF RECEIVER*, "doors")

Receive:
rednet.open("side")
while true do
a, b = rednet.receive()
if b == "doors" then
  redstone.setOutput("back", true)
  sleep(1)
  redstone.setOutput("back", true)
end

To add more commands, add this to sender:
rednet.send(*INSERT ID OF RECEIVER*, "command")

and this to receiver:
if b == "command" then
  --add code here
end


#3 XxLOLdudexX

  • New Members
  • 6 posts

Posted 18 June 2012 - 06:32 PM

View PostComputerCraftFan11, on 01 April 2012 - 08:10 PM, said:

View Postawesomekaj, on 01 April 2012 - 05:00 PM, said:

I'm trying to make a nuclear powerplant (using industrialcraft) with a main console, this console is going to have a gui and options to control reactor cooling and doors, shutters, power distribution etc. Of course one redstone output won't be enough to make this work. So I decided to make it transmit messages via wireless modems and rednet to other pc's that then execute commands, in this case mostly activating redstone currents. Being new to coding in general, how could i do this?
(my current version of minecraft is 1.1 because i'm using tekkit)


Sender:
rednet.open("side of modem")
rednet.send(*INSERT ID OF RECEIVER*, "doors")

Receive:
rednet.open("side")
while true do
a, b = rednet.receive()
if b == "doors" then
  redstone.setOutput("back", true)
  sleep(1)
  redstone.setOutput("back", true)
end
you mean false? true then false, or then doors would be stuck open.

To add more commands, add this to sender:
rednet.send(*INSERT ID OF RECEIVER*, "command")

and this to receiver:
if b == "command" then
  --add code here
end


#4 kaiman

  • New Members
  • 2 posts

Posted 26 December 2012 - 01:29 AM

this script is not working, why doe it expect to end at line:2?

#5 GravityScore

  • Members
  • 782 posts
  • LocationLand of Meh

Posted 26 December 2012 - 06:18 AM

That wasn't a full script - I think ComputerCraftFan11 intended it to be something to lead you in the right direction, not for you to use it as it is.

Anyway, fixed version (he forgot to end the while true statement):
Again, this is also to lead you in the right direction, not be a complete working application.

rednet.open("side")
while true do
  local a, b = rednet.receive()
  if b == "doors" then
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
  elseif b == "reactor off" then
	redstone.setOutput("right", false)
  elseif b == "reactor on" then
	redstone.setOutput("right", true)
  end
  -- Add more elseif statements to add more commands
end

rednet.open("side")
rednet.send(ID OF SENDER, "doors")
rednet.send(ID OF SENDER, "reactor on")
sleep(10)
rednet.send(ID OF SENDER, "reactor off")






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users