Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- -- RailServer v.1.9 --
- ----------------------
- -- Variables Input
- -- Insert the name of your train in quotation marks.
- -- 18 Characters please, if name less than 18 chars
- -- insert spaces to make up difference
- local trainname = "Test Train 3 "
- -- Set the Train Departure Time
- -- note time is number format eg. 18.30 = 18.5
- local traintime = 23
- -- Set the Train Destination
- -- all lowercase no caps
- local destination = destination1
- -- Set the Train Destination Name
- local destinationname = "Destination 1"
- -- Set the Platform (north, south, east, west)
- local platform = south
- -- Input Platform Number (platforms 3-6)
- local platformnumber = 3
- -- Input length of time train to sit on platform
- -- eg 1.5 = an hour and a half mc gametime
- local platformdelay = 1
- -- and in real world seconds
- local platformdelaysecs = 48
- --- Total Creation Time (important Variable)
- --- Time for 7 carts at current variables is 1.5
- local creationtime = 1.5
- -- Select req. Carts (all lowercase no spaces)
- local cart1 = passenger
- local cart2 = passenger
- local cart3 = passenger
- local cart4 = none
- local cart5 = none
- local cart6 = none
- local cart7 = anchor
- --Speed Variables
- --Time for Locomotive in secs
- local locotime = 35
- --Time between carts secs
- local carttime = 5
- --Number of carts intrain
- local cartnumber = 7
- --Time after last cart before platform deselect
- local endtime = 5
- ---Redstone Connections (construction notes)
- --- right - bundled Cable to platform selectors
- --- bottom - system will only operate if a redstone signal is active
- -- Functions
- function cartFreq(comp1,comp2,name)
- print(name.." Cart")
- rednet.send(comp1, "pulse")
- rednet.send(comp2, "pulse")
- end
- function cartFreq2(comp1,name)
- rednet.send(comp1, "pulse")
- print(name.." Cart")
- end
- function passenger()
- cartFreq2(229, "Passenger")
- end
- function storage()
- cartFreq2(230, "Storage")
- end
- function anchor()
- cartFreq2(231, "Anchor")
- end
- function work()
- cartFreq2(232, "Work")
- end
- function undercutter()
- cartFreq2(233, "Undercutter")
- end
- ---Liquid Table Functions
- function water()
- cartFreq(167, 160, "Water")
- end
- function lava()
- cartFreq(165, 171, "Lava")
- end
- function creosote()
- cartFreq(168, 172, "Creosote")
- end
- function biofuel()
- cartFreq(169, 173, "Biofuel")
- end
- function oil()
- cartFreq(170, 174, "Oil")
- end
- function fuel()
- cartFreq(166, 175, "Fuel")
- end
- ---Blocks Table Functions
- function cobble()
- cartFreq(178, 179, "Cobble")
- end
- function stone()
- cartFreq(180, 181, "Stone")
- end
- function stoneslab()
- cartFreq(182, 183, "Stone Slab")
- end
- function stonebrick()
- cartFreq(184, 185, "Stone Brick")
- end
- function dirt()
- cartFreq(186, 187, "Dirt")
- end
- function gravel()
- cartFreq(188, 189, "Gravel")
- end
- function oakwood()
- cartFreq(190, 191, "Oak Wood")
- end
- function glass()
- cartFreq(192, 193, "Glass")
- end
- function sandstone()
- cartFreq(194, 195, "Sandstone")
- end
- function csandstone()
- cartFreq(196, 197, "C Sandstone")
- end
- function sand()
- cartFreq(198, 199, "Sand")
- end
- function basalt()
- cartFreq(200, 201, "Basalt")
- end
- function marble()
- cartFreq(202, 203, "Marble")
- end
- function obsidian()
- cartFreq(204, 205, "Obsidian")
- end
- ---Fuel Table Functions
- function blazerod()
- cartFreq(206, 207, "Blaze Rod")
- end
- function charcoal()
- cartFreq(208, 209, "Charcoal")
- end
- function coalcoke()
- cartFreq(210, 211, "Coal Coke")
- end
- function electricity()
- cartFreq(176, 177, "Electricity")
- end
- ---Destination Functions
- function destination1()
- cartFreq2(212, "Destination 1")
- end
- function destination2()
- cartFreq2(213, "Destination 2")
- end
- function destination3()
- cartFreq2(214, "Destination 3")
- end
- function destination4()
- cartFreq2(215, "Destination 4")
- end
- function destination5()
- cartFreq2(216, "Destination 5")
- end
- function destination6()
- cartFreq2(217, "Destination 6")
- end
- function destination7()
- cartFreq2(161, "Destination 7")
- end
- function destination8()
- cartFreq2(218, "Destination 8")
- end
- function destination9()
- cartFreq2(219, "Destination 9")
- end
- function destination10()
- cartFreq2(220, "Destination 10")
- end
- function destination11()
- cartFreq2(221, "Destination 11")
- end
- function destination12()
- cartFreq2(222, "Destination 12")
- end
- function destination13()
- cartFreq2(213, "Destination 13")
- end
- function destination14()
- cartFreq2(214, "Destination 14")
- end
- function destination15()
- cartFreq2(215, "Destination 15")
- end
- function destination16()
- cartFreq2(216, "Destination 16")
- end
- function destination17()
- cartFreq2(217, "Destination 17")
- end
- function destination18()
- cartFreq2(212, "Destination 18")
- end
- function none()
- print("No Cart Selected....Moving On...")
- end
- -- Cartpulse Function
- function cartpulse(carttype,platform)
- carttype()
- end
- -- Destinationpulse Function
- function destinationpulse(destination,platform)
- destination()
- end
- function platformselect(platform)
- if platform == south
- then
- rs.setBundledOutput("right",colors.blue)
- print("Platform 3 Selected")
- elseif platform == east
- then
- rs.setBundledOutput("right", colors.green)
- print("Platform 4 Selected")
- elseif platform == north
- then
- rs.setBundledOutput("right", colors.red)
- print("Platform 5 Selected")
- else
- print("Platform 6 Selected")
- end
- end
- function platformdeselect()
- rs.setBundledOutput("right",0)
- end
- function redcheckfalse()
- print("Automatic trains are being held!")
- print("This computer will reboot in 30 seconds")
- sleep(30)
- os.reboot()
- end
- function redcheck()
- if rs.getInput("bottom") == true then
- redcheckfalse()
- else
- print("Automatic trains are not currently being held")
- end
- end
- local totalcarttime = carttime*cartnumber
- local totalwaittime = totalcarttime+locotime+endtime
- local totaltime = totalwaittime+platformdelaysecs
- local traincreatetime = traintime-platformdelay-creationtime
- local traintimeactual = os.setAlarm(traincreatetime)
- while true do
- local event, arg = os.pullEvent("alarm")
- if arg == traintimeactual then
- redcheck()
- print("Train Creation in Progress")
- rednet.send(242, trainname.." Platform "..platformnumber.." "..destinationname.." "..textutils.formatTime(traintime,true))
- print("Data Sent to Departures Board")
- print(trainname)
- platformselect(platform)
- print("Time to deselection"..totalwaittime.."secs")
- print("Time to train departure"..totaltime.."secs")
- destinationpulse(destination,platform)
- sleep(locotime)
- cartpulse(cart1,platform)
- sleep(carttime)
- cartpulse(cart2,platform)
- sleep(carttime)
- cartpulse(cart3,platform)
- sleep(carttime)
- cartpulse(cart4,platform)
- sleep(carttime)
- cartpulse(cart5,platform)
- sleep(carttime)
- cartpulse(cart6,platform)
- sleep(carttime)
- cartpulse(cart7,platform)
- sleep(carttime)
- sleep(endtime)
- print("Ready to Board")
- platformdeselect()
- print("Platform Deselected")
- sleep(platformdelaysecs)
- print("Train Departing for "..destinationname)
- sleep(2)
- print("This Computer Will reboot in 10 secs")
- print("Thank you for using Megatech RailServer v1.8")
- sleep(10)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment