Posted 28 March 2012 - 11:17 AM
Alright so I've adapted two samples provided on these forums for an ice machine process used to cool down my IC reactors. I'm not looking for anyone to do any of it for me, but I'm wondering if I can get help on three things; (code below)
I've used the built in help, but when I try to detect, it breaks the script. I guess I need some help with the formatting and/or some direction.
1.
I have two files, the start-up runs through the various components, and prints reports. Right now, they are simply dummy text, but my goal is to display states based on true or false; e.g. Detect a color input on the bundled cable and print either text and/or a value.
So lets say I have 3 power storage units that output when full. On power-up, the test will check the bundled cable, red wire to see if a RS signal is true.
How could I pull that variable and include in print("Unit 1 is [state]" where state is FULL or CHARGING. I get if bundled cable red is true, then print(…) but all my efforts have failed.
is it;
2.
Once it is detected, I'm completely lost on read.io; I wanted to give the option to start ice production if supply is low. So if my counter reads 64, it should throw the "Low Supply" and ask if you'd like to turn on the Snow Collector Array. (SCA)
The SCA is controlled by a second program (See below) called control, also adopted. I tried to set the output with;
If I got the above to work, I imagine the control program would reset the wire state.
Lastly, 3 ..
If I wanted to make some momentary switches, or choose to send a timed pulse to a specific wire, how would I format it?
I'm still learning timers and loops and I believe that's the way here.
Any help and direction is greatly appreciated!
Code
startup
control
I've used the built in help, but when I try to detect, it breaks the script. I guess I need some help with the formatting and/or some direction.
1.
I have two files, the start-up runs through the various components, and prints reports. Right now, they are simply dummy text, but my goal is to display states based on true or false; e.g. Detect a color input on the bundled cable and print either text and/or a value.
So lets say I have 3 power storage units that output when full. On power-up, the test will check the bundled cable, red wire to see if a RS signal is true.
How could I pull that variable and include in print("Unit 1 is [state]" where state is FULL or CHARGING. I get if bundled cable red is true, then print(…) but all my efforts have failed.
is it;
if rs.getBundledInput(back,red) == true then
print("Red Unit FULL")
else
print("Red Unit Charging")
2.
Once it is detected, I'm completely lost on read.io; I wanted to give the option to start ice production if supply is low. So if my counter reads 64, it should throw the "Low Supply" and ask if you'd like to turn on the Snow Collector Array. (SCA)
Do you want to start ice collection now? y to start | n to continue...
The SCA is controlled by a second program (See below) called control, also adopted. I tried to set the output with;
if rs.getBundledInput(back,blue) == true then
rs.setBundledOutput(back,green) == true
If I got the above to work, I imagine the control program would reset the wire state.
Lastly, 3 ..
If I wanted to make some momentary switches, or choose to send a timed pulse to a specific wire, how would I format it?
I'm still learning timers and loops and I believe that's the way here.
Any help and direction is greatly appreciated!
Code
startup
--EvBios System Check .v03
--Adapted from original by unknown
--Ready the Terminal
local function clearScreen()
term.clear()
term.setCursorPos(1, 1)
end
--Start the Built In Test
print("Power On BIT Started:")
sleep(3)
term.setCursorPos(1, 5)
print("EvBIOS v.03")
sleep(3)
term.setCursorPos(1, 7)
print("Bundled Cable Detected")
sleep(2)
term.setCursorPos(1, 9)
print("Loading Management Profile...")
sleep(3)
term.setCursorPos(31, 9)
print("COMPLETE")
sleep(3)
clearScreen()
--Check the Asset System
print("Checking Asset System..|")
sleep(3)
term.setCursorPos(1, 3)
print("Ice System Reports Low Supply!")
sleep(1)
term.setCursorPos(1, 5)
print("Compressors ONLINE")
sleep(1)
term.setCursorPos(1, 7)
print("All Filters ONLINE")
sleep(1)
term.setCursorPos(1, 9)
print("Collectors ONLINE")
sleep(1)
term.setCursorPos(1, 11)
print("Transposers ONLINE")
sleep(6)
clearScreen()
--Check the Blutricity and Sorting System
print("Checking Sorting System../")
sleep(3)
term.setCursorPos(1, 3)
print("Blutricity Grid ONLINE")
sleep(2)
term.setCursorPos(1, 5)
print("Sorter ONLINE")
sleep(2)
term.setCursorPos(1, 7)
print("Sorter AI Reports:")
sleep(2)
term.setCursorPos(20, 7)
print("READY")
sleep(4)
clearScreen()
--Check the EU Power System
print("Checking Power Subsystem..--")
sleep(3)
term.setCursorPos(1, 3)
print("MV Power Grid Nominal")
sleep(3)
term.setCursorPos(1, 5)
print("Local MFSU Capacity 100%")
sleep(1)
term.setCursorPos(1, 7)
print("Local MFE Capacity 100%")
sleep(1)
term.setCursorPos(1, 9)
print("Local Unit Capacity 100%")
sleep(1)
term.setCursorPos(1, 11)
print("All Power Systems READY")
sleep(4)
clearScreen()
--Check the other stuff
print("Checking System Integration..\\") -- Here is the escaped backslash.
sleep(2)
term.setCursorPos(1, 3)
print("Talkback OK")
sleep(2)
term.setCursorPos(1, 5)
print("CPU READY")
sleep(2)
term.setCursorPos(1, 7)
print("Lag Detected: Downloading More RAM..")
sleep(4)
term.setCursorPos(1, 9)
print("RAM Download COMPLETE")
sleep(3)
clearScreen()
--Check redwire connections
print("Checking Redwire Network..|")
sleep(4)
term.setCursorPos(1, 3)
print("System Integrity 100%")
sleep(2)
term.setCursorPos(1, 5)
print("Removing Safeties")
sleep(2)
term.setCursorPos(1, 7)
print("Disabling Homicidal AI")
sleep(3)
clearScreen()
--BIT Success
print("All Reactor Support System READY")
sleep(1)
term.setCursorPos(1, 3)
print("Operators Must Wear Eye Protection")
sleep(2)
term.setCursorPos(1, 5)
print("Do Not Send Ice to Reactors; OFFLINE")
sleep(4)
term.setCursorPos(1, 8)
print("Loading Interface... Please wait...")
sleep(3)
--Load the control program
shell.run("control")
control
-- Reactor Coolant Control v.03 by Evis
-- Original by Shif
shell.run("clear");
-- Creates 3 arrays, s to store the constant of each color, o to store the toggles and sn to store the names of the toggles
s = {colors.white, colors.red, colors.lightBlue, colors.yellow, colors.blue, colors.black};
o = {"off", "off", "off", "off", "off", "off"};
sn = {"Extract Ice Blocks", "External Power Disconnect", "Supply Snow to Compressors", "Start Snow Collector Array", "Supply Ice to Reactors", "Local MFSU Disconnect"};
-- some placeholders for later
cs = 1;
co = "off";
-- master color variable, the sum of all the color constants of services that are on will be stored here
master = 0;
while true do
shell.run("clear");
-- reset master
master = 6;
print("/// Reactor Coolant Support Controller v.03 ///\n");
-- for loop to check if a toggle is on and if it is then it adds the color value to the master variable
for i=1, 6 do
-- the status variable will store "on" or "off", i use it to convert "on" to "on " so the text doesnt move
status = o[i];
if(o[i] == "on") then
status = status.." ";
master = master + s[i];
end
-- this is what turns each cable on, based on the value of the master variable it decides which cables to turn on
redstone.setBundledOutput("back", master);
-- this prints each of the services and their states
print(i.." - "..status.." - "..sn[i]);
end
-- here it asks for what service to toggle, if the number is not in the list it asks again
sValid = true;
while sValid do
write("\nSelect a service to toggle: ");
cs = read();
-- this took me some painful moments of troubleshooting, if you dont convert what you read() and then try to use it to point inside an array it will point to different data, example: not calling tonumber(cs) and then doing i[cs] would do i["3"] instead of i[3]
cs = tonumber(cs);
if((cs == 1) or (cs == 2) or (cs == 3) or (cs == 4) or (cs == 5) or (cs == 6)) then
sValid = false;
else
print("Invalid Service");
end
end
--here it toggles the service, if its on it turns it off and vice versa
co = o[cs];
if(co == "on") then
o[cs] = "off";
else
o[cs] = "on";
end
end
-- here is where we print detection events
--