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

Working with Railcraft

Started by redeye83, 19 January 2013 - 10:11 PM
redeye83 #1
Posted 19 January 2013 - 11:11 PM
I want to make a train network and have it fully intergrated with computercraft.
I did see a post somewhere on a website (might have been this one) talking about something like this but I cant find it anywhere.

What I'm looking for is for people to help point me in the right direction for writing the programs and setting it up. I want to learn how to do it as I go along. Thought I would start with a small project as my first lol ;-)

Here is a list of what I want/think my system to do:
  • Train Status Board - This will show if a train is at a platform and where that platform will take you
  • Route planning system - When a player gets into a train and presses the go button that signal will tell the "points" how to change so it goes to the right track
  • Train Location Board - This will be for the control room and will show what a train is doing, so for example the train from Pitsea to Basildon is heading to Basildon and the train from Southend to Grays is waiting at grays.
I'm sure there are lots more things I could add but these seem fairly massive so lets start with them.

The train station will work like a real one where players will have to wait for a train to arrive rather than calling a personal train.

I'm not sure if im going to have more than one stop per line and have the train wait for "x" time and then carry on just like real trains.

So any hints/help/ideas please.
dan14941 #2
Posted 20 January 2013 - 02:29 AM
You would have to connect your computers to redstone and monitors and wireless modems if you want this to work as I am not good with rednet I can't help you with that sorry but if you don't know how to make your computer output a redstone signal just ask me!

Ps if you found this helpful click my green "/\" in the corner
|
theoriginalbit #3
Posted 20 January 2013 - 02:38 AM
I'm not too sure, but I'm pretty sure that RailCraft is entirely redstone based meaning you will need to look here ( http://computercraft.info/wiki/index.php?title=Redstone_(API) ) and checkout how to use the redstone functionality of computers.

As for things such as displaying data about trains on platforms and such your best option is to use Rednet to transmit data around your world between computers. Info on the rednet API can be found here ( http://computercraft.info/wiki/index.php?title=Rednet_(API) ).

For displaying data on monitors you will want to take a look into the peripherals API here ( http://computercraft.info/wiki/index.php?title=Peripheral_(API) ).

There will also need to be some kind of data persistence so you will want to look here ( http://computercraft.info/wiki/index.php?title=IO_(API) ) and here ( http://computercraft.info/wiki/index.php?title=Fs_(API) ) and chapter 21 here ( http://www.lua.org/pil/21.html )

If there is anything else you need help with just ask. Feel free to post any code you have done to pastebin to get assistance with any issues quicker too.
redeye83 #4
Posted 20 January 2013 - 04:03 AM
For the display I plan to use the signal from the Railcraft Signals via bundled wire to show the redstone state.

print (redstone.getBundledInput("back"), colors.blue)
if = "true"
print ("+++++++")
else
print ("----------")

The above code is not right I know, but its just showing my thinking. On the monitor I want the train shown with ++++++++ and the track show with ——– that way I can show the progress of the train. I would like to have two types of trains with the highspeed train displayed as ******** but this might get too messy on the screen.
I dont have the advanced monitors as they are not part of techic classic.

Am I thinking in the right direction?
redeye83 #5
Posted 20 January 2013 - 04:53 AM

While x ~= "pie" dp
y = rs.getBundledInput("back")
sleep(1)
if colors.test (y, colors.lime) == true then
print ("++++++++")
sleep(1)
else
if colors.test (y, colors.lime == false then
print ("--------")
sleep(1)
end
end

I found this code here: http://www.computercraft.info/forums2/index.php?/topic/3016-video-bundled-cable-basics

Now I have no idea what the top line means, but he says it makes it repeat. The bottom bit with the prints is what I want it to do, but again I'm not sure if thats right. I hope to upload a picture of what the display will look like to help explain what I'm trying to do.
theoriginalbit #6
Posted 20 January 2013 - 04:58 AM
if you want your program to infinitely loop use this at the top instead of what you have

while true do

this means that the program will continue to run forever until it is either terminated by a user, errors, or the computer is shutdown or rebooted…

So if I'm understanding you correctly the 'trains' are tracked by signal boxes which can output a redstone signal when a 'train' is near by… is that right? ( sorry for the questions, I've never actually used RailCraft's advanced features before, I've always been CC or RP2… )
redeye83 #7
Posted 20 January 2013 - 08:59 AM
Yes in railcraft you have sensors that can detect when a train is between them and output redstone for things like this and also to switch tracks if the track ahead is blocked or hold the train etc.
I will have sensors on each part of my track and check the redstone state of the stations so I can track them there too.
Here is what the display of the "map" will look like:


Key:
- = Empty Track
+ = Train on Track
@ = Empty Station
* = Train at Station
theoriginalbit #8
Posted 20 January 2013 - 10:49 AM
Yes in railcraft you have sensors that can detect when a train is between them and output redstone for things like this and also to switch tracks if the track ahead is blocked or hold the train etc.
I will have sensors on each part of my track and check the redstone state of the stations so I can track them there too.
Here is what the display of the "map" will look like:


Key:
- = Empty Track
+ = Train on Track
@ = Empty Station
* = Train at Station
Yeh ok then, given that its completely possible to do. My main concern was that you were going to have no way to know where the trains were… But you can have it show different chars to the screen too. You will definetly need to look into rednet ( since I'm assuming that track is over quite a large distance ) and the redstone API for the bundled cable control.
dan14941 #9
Posted 20 January 2013 - 12:15 PM
you could use the sensors to send redstone inputs to the commuter and have the computer display it on a monitor
redeye83 #10
Posted 20 January 2013 - 04:15 PM
you could use the sensors to send redstone inputs to the commuter and have the computer display it on a monitor
Yep thats the plan, does anyone know the range of wireless redstone? I would be so much easyer if I could just use that rather than rednet.
theoriginalbit #11
Posted 20 January 2013 - 05:04 PM
you could use the sensors to send redstone inputs to the commuter and have the computer display it on a monitor
Yep thats the plan, does anyone know the range of wireless redstone? I would be so much easyer if I could just use that rather than rednet.
I don't think it has one… I think… Did I say I think :P/>
I'm pretty sure using rednet on a RP2 bundled cable allows it to go further than normal too…
remiX #12
Posted 20 January 2013 - 08:16 PM
you could use the sensors to send redstone inputs to the commuter and have the computer display it on a monitor
Yep thats the plan, does anyone know the range of wireless redstone? I would be so much easyer if I could just use that rather than rednet.

When I use to play tekkit Classic I tested and it worked for 250 blocks, after that I got over testing because that's wayyy more than I needed :P/>
Not sure about FTB, Tekkit Lite, though.
redeye83 #13
Posted 20 January 2013 - 08:54 PM
you could use the sensors to send redstone inputs to the commuter and have the computer display it on a monitor
Yep thats the plan, does anyone know the range of wireless redstone? I would be so much easyer if I could just use that rather than rednet.

When I use to play tekkit Classic I tested and it worked for 250 blocks, after that I got over testing because that's wayyy more than I needed :P/>
Not sure about FTB, Tekkit Lite, though.
I'm running Tekki Classic on my server so it should be fine but to be honest I'm most likly going to use wireless redstone as it takes less time lol
redeye83 #14
Posted 20 January 2013 - 09:22 PM

local monitor = peripheral.wrap("back")
monitor.clear()
while true do
y = rs.getBundledInput("back") 
sleep(1) 
if colors.test (y, colors.purple) == true then 
print ("*----@----@----@----@") 
sleep(1) 
else 
if colors.test (y, colors.purple) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
sleep(1) 
if colors.test (y, colors.red) == true then 
print ("@++++@----@----@----@") 
sleep(1) 
else 
if colors.test (y, colors.red) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.orange) == true then 
print ("@----*----@----@----@") 
sleep(1) 
else 
if colors.test (y, colors.orange) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.white) == true then 
print ("@----@++++@----@----@") 
sleep(1) 
else 
if colors.test (y, colors.white) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.lime) == true then 
print ("@----@----*----@----@") 
sleep(1) 
else 
if colors.test (y, colors.lime) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.blue) == true then 
print ("@----@----@++++@----@") 
sleep(1) 
else 
if colors.test (y, colors.blue) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.cyan) == true then 
print ("@----@----@----*----@") 
sleep(1) 
else 
if colors.test (y, colors.cyan) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.black) == true then 
print ("@----@----@----@++++@") 
sleep(1) 
else 
if colors.test (y, colors.black) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end 
if colors.test (y, colors.magenta) == true then 
print ("@----@----@----@----*") 
sleep(1) 
else 
if colors.test (y, colors.magenta) == false then 
print ("@----@----@----@----@") 
sleep(1) 
end
if colors.test (y, colors.pink) == true then 
print ("	 +		 /") 
sleep(1) 
else 
if colors.test (y, colors.pink) == false then 
print ("	 \		 /") 
sleep(1) 
end
if colors.test (y, colors.green) == true then 
print ("	 \		 +") 
sleep(1) 
else 
if colors.test (y, colors.green) == false then 
print ("	 \		 /") 
sleep(1) 
end
if colors.test (y, colors.pink) == true then 
print ("	  +	   /") 
sleep(1) 
else 
if colors.test (y, colors.pink) == false then 
print ("	  \	   /") 
sleep(1) 
end
if colors.test (y, colors.green) == true then 
print ("	  \	   +") 
sleep(1) 
else 
if colors.test (y, colors.green) == false then 
print ("	  \	   /") 
sleep(1) 
end
if colors.test (y, colors.brown) == true then 
print ("	   *-----@") 
sleep(1) 
else 
if colors.test (y, colors.brown) == false then 
print ("	   @-----@") 
sleep(1) 
end
if colors.test (y, colors.yellow) == true then 
print ("	   @+++++@") 
sleep(1) 
else 
if colors.test (y, colors.yellow) == false then 
print ("	   @-----@") 
sleep(1) 
end
if colors.test (y, colors.gray) == true then 
print ("	   @-----*") 
sleep(1) 
else 
if colors.test (y, colors.gray) == false then 
print ("	   @-----@") 
sleep(1) 
end	 
end
Ok this is the baisc code that I've come up with, whats missing? I've not tested this yet as I'm at work (shhh dont tell the boss) but would like to sort out the code so i can test it as soon as I get home.
theoriginalbit #15
Posted 20 January 2013 - 09:33 PM
Ok this is the baisc code that I've come up with, whats missing? I've not tested this yet as I'm at work (shhh dont tell the boss) but would like to sort out the code so i can test it as soon as I get home.
A monitor and a bundled cable can't be on the same side as a computer and the syntax for elseif's in lua is

if <condition> then
  -- code
elseif <condition> then
  -- code
elseif <condition> then
  -- code
end

That being said your if else statements are a little confusing in the first place with the logic behind them…

EDIT: Also thats a lot of sleeps!!!! :P/>
Edited on 20 January 2013 - 08:40 PM
redeye83 #16
Posted 20 January 2013 - 09:46 PM
thats a very good point I didnt realise they were both set to back lol. As for the logic of my if's there is no real logic, I know what I want but I'm not 100% sure how to do it lol.

if colors.test (y, colors.gray) == true then 
print ("		   @-----*") 
sleep(1) 
else 
if colors.test (y, colors.gray) == false then 
print ("		   @-----@") 
sleep(1) 
end  
so this bit to ME means that if the gray wire gets power it will print what I want and if its not got power it will print the other line and will keep checking every second to see if it has a signal. This is so that the map is live. I then just copy and repeated this. The one thing I may have a problem with is getting it to display on the lines/rows I want it to like it does in the picture above.
theoriginalbit #17
Posted 20 January 2013 - 09:53 PM
ok so before I suggest some improved logic… the colours will be the location of the train on the map? or the type of train it is?
to set the cursor location for printing you can use
term.setCursorPos( x, y )
where x and y are the location on the screen you wish to set it to.

also side note here that code will take a minimum of FAR more than 1 second…

EDIT: oh another thing I just noticed, it will never print to the monitor… you have to redirect the computer to the monitor if you wish to use the print function to print to the monitor

-- after you have wrapped the monitor and want to print to it
term.redirect( monitor )

-- all your program code here

-- at the very end of the program ( or when you want to print on the computer again )
term.restore()
Edited on 20 January 2013 - 08:55 PM
redeye83 #18
Posted 20 January 2013 - 10:12 PM
[indent=1]The colors are for the parts of the map, so Purple is the first Station and Red is the first bit of track. They will change to show where the train is.[/indent]
[indent=1]so would[/indent]
[indent=1]

term.setCursorPos(1,1)
if colors.test (y, colors.magenta) == true then
print ("@----@----@----@----*")
os.pullEvent()
else
if colors.test (y, colors.magenta) == false then
print ("@----@----@----@----@")
os.pullEvent()
end
term.setCursorPos(1,2)
if colors.test (y, colors.pink) == true then
print ("	 +		 /")
os.pullEvent()
else
if colors.test (y, colors.pink) == false then
print ("	 \		 /")
os.pullEvent()
end
[/indent]
[indent=1]Make the output from the pink wire's response go to the next line?[/indent]
[indent=1]Also I changed the sleep to a pullEvent, would that work?[/indent]
theoriginalbit #19
Posted 20 January 2013 - 10:24 PM
[indent=1]The colors are for the parts of the map, so Purple is the first Station and Red is the first bit of track. They will change to show where the train is.[/indent]
[indent=1]Make the output from the pink wire's response go to the next line?[/indent]
[indent=1]Also I changed the sleep to a pullEvent, would that work?[/indent]
Print actually automatically goes to the next line for you… but this is a basic form of how you would do it ( I'm following the same pattern you have for your strings to print, these may need to change later so one string doesn't write over another )…


while true do -- loop forever, unless of error or termination by the user
  term.clear() -- clear the screen for printing
  term.setCursorPos(1,1) -- put the cursor in the top left
  if colors.test( y, colours.magenta ) then
	print("@----@----@----@----*")
  else
	print("@----@----@----@----*")
  end

  if colors.test( y, colors.pink ) then
	print("		 +			   /")
  else
	print("		 \\			   /") -- this needs \\ here because \ is whats known as an escape character
  end

  -- etc, etc, etc

  sleep( 1 ) -- sleep for a second at the VERY END of drawing the whole screen...
end
redeye83 #20
Posted 21 January 2013 - 12:21 AM
Ok I've now managed to confuse myself by trying to work out a question lol.
Basicly If i set the cursor to 1,1 for the first line can I just add the cursor set code but have 1,2 on the if bits so they display on the second line and format right?

Also someone ^^^^ sugested I use FTB for my server so that means I will have Advanced Colour scrrens, where can I find out how to make my code even more complicated with color? lol
theoriginalbit #21
Posted 21 January 2013 - 12:45 AM
Ok I've now managed to confuse myself by trying to work out a question lol.
Basicly If i set the cursor to 1,1 for the first line can I just add the cursor set code but have 1,2 on the if bits so they display on the second line and format right?
Print will automatically move to a new line for you. :)/>

Also someone ^^^^ sugested I use FTB for my server so that means I will have Advanced Colour scrrens, where can I find out how to make my code even more complicated with color? lol
…………………………………………………… that was me… and its not actually more complicated… its about the same… Take a look at term.setBackgroundColor the colours API ( http://computercraft.info/wiki/Colors_(API) )…
redeye83 #22
Posted 21 January 2013 - 01:24 AM
Would it be hard/easyer/pointless to use images made in paint than text?
theoriginalbit #23
Posted 21 January 2013 - 01:29 AM
Would it be hard/easyer/pointless to use images made in paint than text?
harder / pointless id say… gimme a second, I'll quickly write up an example code ( I can't test it so it may have some bugs, but it should give you a fair idea )
theoriginalbit #24
Posted 21 January 2013 - 01:56 AM
Ok so here is some code I wrote up… its incomplete you will have to complete it… I have comments all over the place of notable things i have done explaining why it was done, or what you need to do to finish the code…

I would explain more but I need to wake up in 5 hours so really need to go to bed :/

Good luck, I hope this all makes sense, I should be able to answer any questions you have in the morning…

http://pastebin.com/tTnNdELk

EDIT: Oops just noticed a bug which would make it 'hang' after the first loop… use this code instead…
http://pastebin.com/f57gcEHx
Edited on 21 January 2013 - 01:19 AM
redeye83 #25
Posted 21 January 2013 - 02:31 AM
Cheers, I will give this a test once I get home from work
theoriginalbit #26
Posted 21 January 2013 - 07:54 AM
Cheers, I will give this a test once I get home from work
How'd it go?
redeye83 #27
Posted 21 January 2013 - 01:26 PM

local function findPeripheral( kind )
for _,v in pairs( rs.getSides ) do
  if peripheral.getType( v ) == kind then
   return v
  end
end
return nil
end
What does this bit of code do? Whatever it is does not work (I guess I need to edit it with something?)
ChunLing #28
Posted 21 January 2013 - 01:41 PM
It checks for a peripheral of a specific kind. The kind should be a string matching the type of the peripheral.
theoriginalbit #29
Posted 21 January 2013 - 01:43 PM

local function findPeripheral( kind )
for _,v in pairs( rs.getSides ) do
  if peripheral.getType( v ) == kind then
   return v
  end
end
return nil
end
What does this bit of code do? Whatever it is does not work (I guess I need to edit it with something?)
As ChunLing stated this will check for a given peripheral so that you don't have to specify the side everytime in code ( it makes it more dynamic that way )
so in the code i called it this way

local monitorSide = findPeripheral( "monitor" )
redeye83 #30
Posted 21 January 2013 - 02:17 PM
ok I get this error?

rail :2: bad argument #1 to pairs (table expected, got function)
theoriginalbit #31
Posted 21 January 2013 - 02:58 PM
ok I get this error?

rail :2: bad argument #1 to pairs (table expected, got function)
Oh wow you can tell I was tired when writing that! Make rs.getSides this rs.getSides()
ChunLing #32
Posted 21 January 2013 - 03:01 PM
Whoops, I missed that too. The line should be for _,v in pairs( rs.getSides() ) do
redeye83 #33
Posted 21 January 2013 - 03:13 PM

bios:466: expected string
ChunLing #34
Posted 21 January 2013 - 03:28 PM
Is that the whole error? TOB, what's up?
theoriginalbit #35
Posted 21 January 2013 - 03:29 PM

bios:466: expected string
Well that's a fun error… I can't see any problems in the code I sent… Any ideas Chun?
redeye83 #36
Posted 21 January 2013 - 03:33 PM
yep thats the whole error.
TOB, what parts of this code have I forgotten to edit?
http://pastebin.com/5GCfGWMP
theoriginalbit #37
Posted 21 January 2013 - 03:36 PM
yep thats the whole error.
TOB, what parts of this code have I forgotten to edit?
http://pastebin.com/5GCfGWMP
Ahh that's your problem… Line 19 you changed it from how I had it to a static side instead if searching for a side. Either change it to monitorSide or "right"…

EDIT: also you didn't finish the drawScreen function…
redeye83 #38
Posted 21 January 2013 - 03:43 PM
hmm ok well it kida worked but it has a problem with line 61? says tried to call nil?
I just copy and pasted what you had already put above and edited the colour and position?
theoriginalbit #39
Posted 21 January 2013 - 03:45 PM
Another late night typo. colors.text instead of colors.test … Sorry

I think I need to stop typing code so late and make ppl wait till I wake up…
redeye83 #40
Posted 21 January 2013 - 03:59 PM
Lol maybe

Right its all working now, thanks….but
I want it bigger and in the middle, I've done this and it makes the first line go in the middle but the next one doesn't and when it does the color checks they have been told to go to 1,1 etc.
How do I get it all relative? Do I have to work out the middle and set the positions that way?

local function drawScreen()
term.clear()
term.setCursorPos( sizeX / 2 - #msg / 2, sizeY / 2 )
I cant remember what the text size code is aswell and the wiki is crap, I found it yesterday but now i cant find it
redeye83 #41
Posted 21 January 2013 - 04:04 PM
I tried using

term.setTextScale(3)
But that gives me the attempt to call nil error :(/>
theoriginalbit #42
Posted 21 January 2013 - 04:08 PM
Lol maybe

Right its all working now, thanks….but
I want it bigger and in the middle, I've done this and it makes the first line go in the middle but the next one doesn't and when it does the color checks they have been told to go to 1,1 etc.
How do I get it all relative? Do I have to work out the middle and set the positions that way?

local function drawScreen()
term.clear()
term.setCursorPos( sizeX / 2 - #msg / 2, sizeY / 2 )
I cant remember what the text size code is aswell and the wiki is crap, I found it yesterday but now i cant find it

Yeh pretty much…


I tried using

term.setTextScale(3)
But that gives me the attempt to call nil error :(/>
That is only valid for monitors, not the computer…
redeye83 #43
Posted 21 January 2013 - 04:16 PM
I did this

local function drawScreen()
term.clear()
term.setCursorPos(5,3)
monitor.setTextScale(3)
-- first we draw the default path on the screen
print("----@----")
term.setCursorPos(5,4)
print("----@----")
I'm slowly learning how to read code lol, term. is for the terminal but the term API doesn't have scale listed so I changed it to what you had wrapped the monitor as.

Now to make it color lol
theoriginalbit #44
Posted 21 January 2013 - 04:26 PM
I did this

local function drawScreen()
term.clear()
term.setCursorPos(5,3)
monitor.setTextScale(3)
-- first we draw the default path on the screen
print("----@----")
term.setCursorPos(5,4)
print("----@----")
I'm slowly learning how to read code lol, term. is for the terminal but the term API doesn't have scale listed so I changed it to what you had wrapped the monitor as.
haha :)/> yeh term doesn't have it but the wrapped monitor does… :)/>

btw the default path you can actually just have it in a print like this


*make it centre*
write( *the whole top row in quotes* )
*make it centre*
write( *the whole second row in quotes* )
*make it centre*
write( *the whole third row in quotes* )
etc, etc, etc

its just for the little bits that we need to have it separate so that it only draws over the part its meant to… :)/>
redeye83 #45
Posted 21 January 2013 - 04:45 PM
Right now to make a train status board lol, how hard can it be?
theoriginalbit #46
Posted 21 January 2013 - 04:47 PM
Right now to make a train status board lol, how hard can it be?
Depends on how its to be done…
redeye83 #47
Posted 21 January 2013 - 05:14 PM
I have no idea at the moment lol
It could be done using the signals and redstone again. The signals have 5 states, green, yellow, red, flashing yellow and flashing red. Each state changes depending on what direction the cart is traveling and the flashing ones mean an error with the track.
Green - Line clear
Yellow - Cart traveling away from you
Red - Red Cart traveling towards you.

So the board could read "Pitsea Express - On Time" if the lights are yellow and
Approching for when its red.

It helps if you know Railcraft, but its doable..with some coding help at silly aclock in the morning im sure lol
theoriginalbit #48
Posted 21 January 2013 - 05:42 PM
Yeh I've never known how it works… Wouldn't yellow say departing? And maybe some kind of detector block can be at the station to be able to say "at station"
redeye83 #49
Posted 22 January 2013 - 12:51 AM
Yeh I've never known how it works… Wouldn't yellow say departing? And maybe some kind of detector block can be at the station to be able to say "at station"
Yep that could work, is it possible to use timings to say "Train due in x mins" or Train due at x time"?
theoriginalbit #50
Posted 22 January 2013 - 12:57 AM
Yeh I've never known how it works… Wouldn't yellow say departing? And maybe some kind of detector block can be at the station to be able to say "at station"
Yep that could work, is it possible to use timings to say "Train due in x mins" or Train due at x time"?
Nah that one is probably too hard…
redeye83 #51
Posted 22 January 2013 - 01:54 AM
even for the mighty TOB? :rolleyes:/> lol
Willibilly19 #52
Posted 22 January 2013 - 04:41 AM
If your trains took exactly the same amount of time to arrive at the station each and every time, you could hard code in the times. The best bet for this would be from the last point on the track you can detect the train, time them from that point (signal…or whatever you have that could detect them) and start the timer as soon as the train passes over that point.
UP844 #53
Posted 22 January 2013 - 07:01 AM
I personally have no idea, but there's a youtube video showing it off and the download for all the coding is in the description. I don't have the link and don't want to go find it, but search Applications of Computercraft: Emails and Notifications. It's pretty cool.
redeye83 #54
Posted 22 January 2013 - 07:33 AM
I personally have no idea, but there's a youtube video showing it off and the download for all the coding is in the description. I don't have the link and don't want to go find it, but search Applications of Computercraft: Emails and Notifications. It's pretty cool.
I had a look and his system is nie but not a fan of the email system and it doesnt use RC.
My system is going to be simple, just using signal box's to send restone signals back to computers.

One quick question, does the computer have to touch the monitor or can I run a cable to it?

If your trains took exactly the same amount of time to arrive at the station each and every time, you could hard code in the times. The best bet for this would be from the last point on the track you can detect the train, time them from that point (signal…or whatever you have that could detect them) and start the timer as soon as the train passes over that point.
Is there a timer program in cc or would I have to just count in my head/ with fingers and toes?
theoriginalbit #55
Posted 22 January 2013 - 09:39 AM
Sadly the computer has to touch the monitor.


* detected rs signal *
local startTime = os.clock()

*wait to detect second signal*
print( os.clock() - startTime )
redeye83 #56
Posted 22 January 2013 - 09:53 AM
Sadly the computer has to touch the monitor.


* detected rs signal *
local startTime = os.clock()

*wait to detect second signal*
print( os.clock() - startTime )

ok so how does this script work?
From what I "know" you have said that the term "startTime" will return the value of "os.clock" that will be the CPU time according to the wiki. then you have said to print the cpu clock - cpu clock?
How does it detect the rs signal? Would i use the bundled cable code again? I will be reciving the signal via a bundled cable.
theoriginalbit #57
Posted 22 January 2013 - 10:03 AM
yeh os.clock is mc time…

whatever color the bundled cable is at the points between where you want to measure…

so it would be lime this

local function waitFor( c )
  while not colors.test( rs.getBundledInput( "back" ), c ) do
	sleep(0)
  end
end

waitFor( colors.red )
local startTime = os.clock()

waitFor( colors.lime )
local endTime = os.clock()

print( ( startTime - endTime ) )
you will want to change the colours appropriately

You might want to do a little formatting to get that number into seconds / minutes… but thats the base code…
Edited on 22 January 2013 - 09:04 AM
redeye83 #58
Posted 22 January 2013 - 04:31 PM
Well that kinda worked, gave me a result of -26.15, so now I have a major problem, I've created the worlds crappist time machine! lol

On a better note I have managed to get my departures screen to work well, it shows when a train is approching, at the station and leaving.

Now just designing how the station is going to look with all this tech in it.

Anyone got any tips on how I can get my control room display to look abit nicer?
theoriginalbit #59
Posted 22 January 2013 - 04:34 PM
Well that kinda worked, gave me a result of -26.15, so now I have a major problem, I've created the worlds crappist time machine! lol
Oh thats cause I typed it the wrong way around in the second example… switch the two variables in the print … that should give you a better reading… :P/>


Anyone got any tips on how I can get my control room display to look abit nicer?
Colours… :P/>
redeye83 #60
Posted 22 January 2013 - 04:40 PM
Well that kinda worked, gave me a result of -26.15, so now I have a major problem, I've created the worlds crappist time machine! lol
Oh thats cause I typed it the wrong way around in the second example… switch the two variables in the print … that should give you a better reading… :P/>


Anyone got any tips on how I can get my control room display to look abit nicer?
Colours… :P/>

I have each part of the track coloured to match its cable colour but just having —- and ++++ seems a waste of what this bad boy can do. I want pictures damit! lol with live CCTV feeds and fluffy dice!
theoriginalbit #61
Posted 22 January 2013 - 05:27 PM
I have each part of the track coloured to match its cable colour but just having —- and ++++ seems a waste of what this bad boy can do. I want pictures damit! lol with live CCTV feeds and fluffy dice!
Well just add sensors everywhere and have some kind of mapping software that maps out the players depending on the sensors they are tripping…
redeye83 #62
Posted 22 January 2013 - 05:30 PM
Well just add sensors everywhere and have some kind of mapping software that maps out the players depending on the sensors they are tripping…
If only there was somewhere I could find out how to use ccSensors :rolleyes:/>
theoriginalbit #63
Posted 22 January 2013 - 05:33 PM
If only there was somewhere I could find out how to use ccSensors :rolleyes:/>
Use openCCSensors… ccSensors is buggy as hell and only works in 1.2.5 … only reason remiX and I did the tutorial is because of a HUGE influx of people coming on asking for help with it and virtually no one knows it…

EDIT: Which there is also a minecart sensor ;)/> your system might be able to get better… ;)/>
redeye83 #64
Posted 23 January 2013 - 07:11 AM
For my system just the normal signals in RC will do the job. just need to make the screen look nicer.
The main problem I'm haing at the moment is getting all the tech into my stations but keeping most of it hidden lol
theoriginalbit #65
Posted 23 January 2013 - 11:39 AM
For my system just the normal signals in RC will do the job. just need to make the screen look nicer.
The main problem I'm haing at the moment is getting all the tech into my stations but keeping most of it hidden lol
Lol yeh that can be tricky sometimes…
redeye83 #66
Posted 23 January 2013 - 04:23 PM
I'm going to be formatting the display code later and wated to know if there was an easy way to work out what size text will fit what size screen and also how to make sure all my text is going to be where I want it. Will it just be a case of trial and error?
I will have to have 18 lines of text displayed and the board will have 3 rows of info and can be as wide as it needs to be i guess, whats the max size of a monitor?
theoriginalbit #67
Posted 23 January 2013 - 04:31 PM
as far as I'm aware its pretty much trial and error when using text scale… you can use term.getSize() which returns width and height… altho I haven't checked what it returns when scaling the text…
redeye83 #68
Posted 25 January 2013 - 04:39 AM
How much server lag does having computers running make? I plan to have a computer on each platform as well as a big departures screen, is this a good idea?
Cranium #69
Posted 25 January 2013 - 09:29 AM
Computers don't generally creat tons of lag. The only time you're going to get noticable lag is when you are either refreshing a screen ridiculously fast, or when you are spamming rednet. From what I understand, rednet was a problem in earlier versions of CC.
redeye83 #70
Posted 25 January 2013 - 10:38 AM
I dont use rednet so thats not a problem, I update the screen everytime a train moves to a new part of the track but I dont think that should make too much problem.
TheOddByte #71
Posted 25 January 2013 - 10:54 AM
I'll love it if we build this on the server tomorrow and it will be alot easier to help you when we are In game so I can both see how you are building it and how you are programming it!
And I quit school tomorrow 15.00(3pm I Think) so I'll hope the server atleast will be up around 17.00(5pm).
dan14941 #72
Posted 27 January 2013 - 02:27 PM
I'll love it if we build this on the server tomorrow and it will be alot easier to help you when we are In game so I can both see how you are building it and how you are programming it!
And I quit school tomorrow 15.00(3pm I Think) so I'll hope the server atleast will be up around 17.00(5pm).
can i join and help?
redeye83 #73
Posted 27 January 2013 - 03:03 PM
can i join and help?
Still waiting for his server to go live
redeye83 #74
Posted 27 January 2013 - 04:08 PM
I'm currently working on a cart system now as the MOD I wanted to use conflicts with everything and is crap when you do get it to work :-(
redeye83 #75
Posted 28 January 2013 - 04:15 AM
Ok so my station design is getting a little out of hand I want 2 computers per platform with the station having 4 platforms, then I want a big departures board showing the status of all 4 platforms (each platform has 2 sides so thats 8 signals), thats just to track the location of each train in the station, then I want my tracking software in the main control room that tracks the status of every track outside of the station so I can track cart locations. I would also like a board in the main control room that showed the status of other stations (so ones not including the one its in)

Is it me or will I run out of room for all thes bundled cables and wireless redstone bits, should I bite the bullet and go rednet? I really dont want to as I just(with lots of help) about know how to use my current setup lol.
TheOddByte #76
Posted 30 January 2013 - 12:05 PM
I'll love it if we build this on the server tomorrow and it will be alot easier to help you when we are In game so I can both see how you are building it and how you are programming it!
And I quit school tomorrow 15.00(3pm I Think) so I'll hope the server atleast will be up around 17.00(5pm).
can i join and help?
Well Sure But Write Your IGN and such on this topic so it won't get all off Topic on this topic.
latemail #77
Posted 06 February 2013 - 01:43 AM
Is it me or will I run out of room for all thes bundled cables and wireless redstone bits, should I bite the bullet and go rednet? I really dont want to as I just(with lots of help) about know how to use my current setup lol.


( Sorry for my bad english, but I try to explain what I have in mind: )

If you decide to do a new setup, maybe think about some string-operation?!? install a sensor for each track/station etc. and get the status via modem in your terminal.
Then - if you like to update your display - just check each status and depending on the findings set up some strings, which then can be print on the display:

[first setup]
string1 = "—–"
string2 = "X"
string3 = "@"
string4 = …………..

[check status in a loop for all sensors]
if status = on then
string_out_1 = string1
else
string_out_1 = string2
end

print (string_out_1..string_out_2..string_out_3)

hope you get the idea, its just a rough scheme ;)/> ???
theoriginalbit #78
Posted 06 February 2013 - 02:36 AM
hope you get the idea, its just a rough scheme ;)/> ???
This is already been done and pretty sure was suggested on page 1 maybe 2.
Cranium #79
Posted 06 February 2013 - 03:59 AM
Y'know, if Tekkit would just add Miscperipherals, this would be sooooo much easier.
redeye83 #80
Posted 06 February 2013 - 04:15 AM
Y'know, if Tekkit would just add Miscperipherals, this would be sooooo much easier.
I will be adding that and another one like it later today as a matter of fact.
There will be a video of our work on this project in the next coming weeks/months. Its all ready we are just working on a larger scale to fully test it out. I'm very happy with it so far and thanks for all the help from you guys.
theoriginalbit #81
Posted 06 February 2013 - 04:16 AM
Y'know, if Tekkit would just add Miscperipherals, this would be sooooo much easier.
And OCS
redeye83 #82
Posted 06 February 2013 - 04:19 AM
And OCS
Whats OCS?

I plan on adding Immibis' Peripherals, and MiscPeripherals
theoriginalbit #83
Posted 06 February 2013 - 04:24 AM
OpenCcSensors (OCS).
redeye83 #84
Posted 06 February 2013 - 04:26 AM
I'm sure if my team ask my nicely i will add that too lol.
theoriginalbit #85
Posted 06 February 2013 - 04:27 AM
ADD IT IN!!! :P/> :P/> :P/>
redeye83 #86
Posted 06 February 2013 - 04:33 AM
Djerun #87
Posted 06 February 2013 - 05:17 PM
edit: whoops didnt see all the other pages
Mikeemoo #88
Posted 06 February 2013 - 10:00 PM
OCS is due to be added into the dev build of tekkit lite.