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

Automated Subway Line?

Started by Shnoiv, 13 June 2014 - 01:23 PM
Shnoiv #1
Posted 13 June 2014 - 03:23 PM
Fairly new to Computer Craft, but have some exposure (Java in AP Computer Science) to computer programming. Want to understand how I could build an automated subway line using computer craft in a control tower. I run Unleashed, so we have Steve's Carts and Railcraft as well to help out. Anyone have any idea?
RoD #2
Posted 13 June 2014 - 10:29 PM
You will need to learn about:
Computercraft rednet;
Variables (quite diferent from the java but easy to understand);
Computercraft redstone output (and maybe input as well);

Some links:
http://computercraft.info/wiki/Rednet_(API)
http://computercraft.info/wiki/Rednet_message_(event)
http://computercraft.info/wiki/Redstone_(API)
http://www.lua.org/pil/contents.html
http://lua-users.org/

Good luck, any questions in detail you can pm. :)/>
Neywiny #3
Posted 14 June 2014 - 02:01 AM
As somebody that likes to map things out, I can help a bit here. Essentially what you need is routing, since you have railcraft, but that might not be what you want. what you are going to want to do if you do routing is have a computer and a ticket machine from openperipherals. Another way, which is for me easier since I don't know that much on routing, would be simply having every computer needed in range of each other, and for long distance repeater computers that use the stock repeat command that comes with cc, but if that doesn't work then you could just do something like this

rednet.open("insert side here")
While true do
   id,msg,dis = rednet.receive --made sure that is spelled correctly
   rednet.broadcast(msg)
end
which just waits for a message and repeats it.

As for the main computer, tables are how you'd do it. for example, you'd do something like

rednet.open("insert side here")
pool = {1,4,6,8,9}
input = read()
if input == "pool" then
	 for k,v in ipairs(pool) do
		  rednet.broadcast(v)
	 end
end
Then every switch you'd have a computer like this

rednet.open("insert side here")
while true do
	 id, msg = rednet.receive()
	 if msg == "user designated id" then
	 rs.setOutput("side track is on","true")
	 while true do
			cart = rs.getInput("side of a redstone line from a detector rail")
			if cart == "true" the
				 rs.setOutput("side track is on","false")
				 break
			else
			end
	 end
end
that would wait for a signal, and if that signal is the right number it would keep redstone on one side on until it gets a pulse, from a detector track or other detector. Sorry for the long post, but a station is harder than just putting down 16 tracks with lines, which could be what you want. If you really wanted, you could have a computer in a control tower that detects the rednet signals and outputs a map on a monitor accordingly, and I can help with that but that'd be a real pain time wise, yet quite simple. That computer, if hidden could have if mfr in on, sine it has bundled cable, could detect and display 80 switches, since it would run 5 sides, one for the monitor and 6 per block, with each bundled cable having 16 colors, so thats something like 80 different destinations max, just on that one computer. you could potentially like up infinite computers and make infinite monitors (mystcraft for resources) that each detect and display a different range of numbers.
Edited on 14 June 2014 - 12:08 AM
TheGreekMan2 #4
Posted 16 June 2014 - 06:56 AM
using wireless modems and chunkloaders so you can have multiple stations blabla
you can download a touch screen api and have monitors set up that emit a wireless redstone signal that changes the track (railcraft) which would take you to the new destination
so basically if you click this (on a monitor) activate a redstone signal that opens up a certain path etc etc