Ok, I am starting to build my factory automation program, but I am running into a problem. If I start up my cobble farm, it runs great. BUT when I try to shut it down, it replies shutdown, but it stays running. I have to shut down the computer to turn off the signal.
print("Welcome to the factory")
sleep(1)
print("Please make your selection")
sleep(1)
print("****************************")
print("* 1.Cobble stone generator *")
print("* 2. Flax farm *")
print("* 3. Ice generator *")
print("****************************")
input = read()
if input == "1" then
print("Cobble generator on/off?")
input = read()
if input == "on" then
redstone.setBundledOutput("bottom", "16", true)
sleep(1)
print("Cobble generator running")
elseif input == "off" then
redstone.setBundledOutput("bottom", "16", false)
sleep(1)
print("Cobble generator shut down")
end
elseif input == "2" then
print("Please wait while the farm cycles")
sleep(2)
redstone.setBundledOutput("bottom", "32768", true)
sleep(2)
redstone.setBundledOutput("bottom", "32768", false)
print("String and seeds on the way")
print("Check chest to your right")
sleep(2)
print("Replanting new flax, please wait")
sleep(2)
redstone.setBundledOutput("bottom", "2048", true)
sleep(2)
redstone.setBundledOutput("bottom", "2048", false)
print("Flax replanted")
elseif input == "3" then
print("Ice generator on/off?")
input = read()
if input == "on" then
redstone.setBundledOutput("bottom", "1024", true)
print("Pumps running")
elseif input == "off" then
redstone.setBundledOutput("bottom", "1024", false)
print("Pumps shut down")
end
end
Same goes for the flax farm.. Anyone have any idea what I am missing? It looks right to me. I have updated to the v1.11 in hopes that the bundled cable issue would fix my problem, but no luck.
Attach it to a chest and if you win, hav it pump out how many you want. If forestry is used you can use the electrical engines to pull an entire stack. Ack now that I think about it, that would be a stupid amount of code. :S
Rollback Post to RevisionRollBack
Server setup in progress, IC2/RP2/BC/Computercraft/ keep an eye on the updates! Register on the forums HERE and take a look!
to get a color value on a bundled cable just use 2^ (whatever power) to get the number (i.e 2^3 = 8; 2^4 = 16, etc). But also he has set it up even easier. Use rs.setBundledOutput("<side>", colors.<colorname>) where <side> is naturally which side of the computer and <colorname> is one of the 16 different colors. The same applies to getting an incoming color.
Description:
It's a calculator that can actually parse expressions.
You know all those ones that ask you "Do you want to add, subtract, multiply or divide? What's the first number? What's the second number?"? It's not that.
Example transcript, what I typed is in italics.
> calc
Welcome to immicalc.
This software is public domain.
Enter expressions, one per line.
Enter 'quit' to quit.
1+1
Answer: 2
1+2+3+4+5
Answer: 15
7+(5*5/(9+10))
Answer: 8.315789
pi
Answer: 3.1415927
pow(e, pi) - pi
Answer: 19.9991 (note: this is the correct answer, it is NOT supposed to be 20...)
cos(pi/4)
Answer: 0.70710677
1/0
Answer: inf (infinity)
inf - inf
Answer: nan (not a number)
quit
>
List of functions:
abs(N)
acos(N)
asin(N)
atan(N)
atan2(Y, X)
ceil(N)
floor(N)
cos(N)
sin(N)
tan(N)
cosh(N)
sinh(N)
tanh(N)
exp(N) -- e to the power of N
ln(N) -- natural log
log(N) -- equal to ln(N)/ln(10)
pow(X, Y) -- X to the power of Y
min(A, B, C...) -- takes any number of arguments
max(A, B, C...) -- takes any number of arguments
sqrt(N) -- equal to pow(N, 0.5)
random() -- returns a random value between 0 and 1
random(max) -- returns a random integer between 1 and max inclusive
random(min, max) -- returns a random integer between min and max inclusive
Ok, I am starting to build my factory automation program, but I am running into a problem. If I start up my cobble farm, it runs great. BUT when I try to shut it down, it replies shutdown, but it stays running. I have to shut down the computer to turn off the signal.
print("Welcome to the factory")
sleep(1)
print("Please make your selection")
sleep(1)
print("****************************")
print("* 1.Cobble stone generator *")
print("* 2. Flax farm *")
print("* 3. Ice generator *")
print("****************************")
input = read()
if input == "1" then
print("Cobble generator on/off?")
input = read()
if input == "on" then
redstone.setBundledOutput("bottom", "16", true)
sleep(1)
print("Cobble generator running")
elseif input == "off" then
redstone.setBundledOutput("bottom", "16", false)
sleep(1)
print("Cobble generator shut down")
end
elseif input == "2" then
print("Please wait while the farm cycles")
sleep(2)
redstone.setBundledOutput("bottom", "32768", true)
sleep(2)
redstone.setBundledOutput("bottom", "32768", false)
print("String and seeds on the way")
print("Check chest to your right")
sleep(2)
print("Replanting new flax, please wait")
sleep(2)
redstone.setBundledOutput("bottom", "2048", true)
sleep(2)
redstone.setBundledOutput("bottom", "2048", false)
print("Flax replanted")
elseif input == "3" then
print("Ice generator on/off?")
input = read()
if input == "on" then
redstone.setBundledOutput("bottom", "1024", true)
print("Pumps running")
elseif input == "off" then
redstone.setBundledOutput("bottom", "1024", false)
print("Pumps shut down")
end
end
Same goes for the flax farm.. Anyone have any idea what I am missing? It looks right to me. I have updated to the v1.11 in hopes that the bundled cable issue would fix my problem, but no luck.
So after not being able to find a password program that couldn't be terminated by Ctrl+T I decided to make my own. It doesn't have a bunch of bells and whistles but it gets the job done. If you decide to edit and redistribute please credit me for the original work.
--Cant be Terminated Security Password
--Created by ShicKla
--Please dont claim as own. Give credit where it is due
password = "default"
aLoop = true
aLine = ""
while aLoop do
term.clear()
term.setCursorPos( 1,1 )
print "Enter Password: "
term.write( aLine )
term.setCursorBlink( true )
aEvent,param = os.pullEvent()
if aEvent == "char" then
aLine = aLine..param
elseif aEvent == "key" then
if param == 29 or param == 157 then
print ""
print "Shutting Down"
sleep(1)
os.shutdown()
elseif param == 28 then
if aLine == password then
aLoop = false
print ""
term.write( os.version() )
print ""
else
aLine = ""
end
elseif param == 14 then
bLine = aLine
aLine = string.sub( bLine,1,-2 )
end
end
end
and replace the things in brackets with the appropriate thing but the first and second [side] must be the same side.
This would check whats on and add the color you want to it or you could replace the + with a - to remove the color.
I'm in the process or re-writing my script. I will have a master program call sub-programs to make changes to machines/reactors/lights and whatnot. Thanks for the help guys!
Rollback Post to RevisionRollBack
Server setup in progress, IC2/RP2/BC/Computercraft/ keep an eye on the updates! Register on the forums HERE and take a look!
I just "completed" my calculator on my computercraft server :smile.gif:
Name of program: DoomCalc Functions: Math (+ - * /) Download link/Copy of code:
CalcOP = "+"
DoomCalc = true
CalcNum1 = 0
CalcNum2 = 0
CalcResult = 0
CalcPos = 1
while DoomCalc do
waitForPress = true
term.clear()
term.setCursorPos (1, 5)
print (" -------------")
print ("| |")
if CalcNum1 < 10 and CalcNum1 > -1 then
term.setCursorPos (7, 6)
elseif CalcNum1 < 100 and CalcNum1 > -10 then
term.setCursorPos (6, 6)
elseif CalcNum1 < 1000 and CalcNum1 > -100 then
term.setCursorPos (5, 6)
elseif CalcNum1 < 10000 and CalcNum1 > -1000 then
term.setCursorPos (4, 6)
elseif CalcNum1 < 100000 and CalcNum1 > -10000 then
term.setCursorPos (3, 6)
end
print (CalcNum1)
term.setCursorPos (8, 6)
print (CalcOP)
term.setCursorPos (9, 6)
print (CalcNum2)
print ("|*************|")
print ("| |")
print ("| + |")
print ("| - |")
print ("| * |")
print ("| / |")
print ("| quit |")
print ("| |")
print ("| |")
print ("| |")
print ("| |")
print ("|*************|")
print ("| |")
print (" -------------")
if numb == 200 then
CalcPos = CalcPos - 1
elseif numb == 208 then
CalcPos = CalcPos + 1
end
if CalcPos > 7 then
CalcPos = 7
elseif CalcPos < 1 then
CalcPos = 1
end
if CalcPos == 1 then
term.setCursorPos (10, 6)
print ("---- <--")
if numb == 28 then
CalcOP = "+"
waitForPress = false
end
elseif CalcPos == 2 then
term.setCursorPos (10, 7)
print ("---- <--")
if numb == 28 then
CalcOP = "-"
waitForPress = false
end
elseif CalcPos == 3 then
term.setCursorPos (10, 8)
print ("---- <--")
if numb == 28 then
CalcOP = "*"
waitForPress = false
end
elseif CalcPos == 4 then
term.setCursorPos (10, 9)
print ("---- <--")
if numb == 28 then
CalcOP = "/"
waitForPress = false
end
elseif CalcPos == 5 then
term.setCursorPos (10, 10)
print ("---- <--")
if numb == 28 then
DoomCalc = false
waitForPress = false
end
elseif CalcPos == 6 then
term.setCursorPos (10, 12)
print ("---- <--")
if numb == 28 then
term.setCursorPos (8, 13)
print (CalcNum2)
term.setCursorPos (3, 16)
print (CalcResult)
term.setCursorPos (8, 12)
CalcNum1__ = read()
CalcNum1_ = tonumber (CalcNum1__)
CalcNum1 = math.floor (CalcNum1_)
if CalcNum1 == nil then
CalcNum1 = 0
end
waitForPress = false
end
elseif CalcPos == 7 then
term.setCursorPos (10, 13)
print("---- <--")
if numb == 28 then
term.setCursorPos (8, 12)
print (CalcNum1)
term.setCursorPos (3, 16)
print (CalcResult)
term.setCursorPos (8, 13)
CalcNum2__ = read()
CalcNum2_ = tonumber (CalcNum2__)
CalcNum2 = math.floor (CalcNum2_)
if CalcNum2 == nil then
CalcNum2 = 0
end
waitForPress = false
end
end
if CalcOP == "+" then
CalcResult = CalcNum1 + CalcNum2
elseif CalcOP == "-" then
CalcResult = CalcNum1 - CalcNum2
elseif CalcOP == "*" then
CalcResult = CalcNum1 * CalcNum2
elseif CalcOP == "/" then
CalcResult = CalcNum1 / CalcNum2
end
term.setCursorPos (8, 12)
print (CalcNum1)
term.setCursorPos (8, 13)
print (CalcNum2)
term.setCursorPos (3, 16)
print (CalcResult)
numb = "nil"
if waitForPress then
type, numb = os.pullEvent()
end
end
term.clear()
term.setCursorPos (1, 1)
A description: A basic calculator with fairly advanced UI that I made for my "operating system". I'm pretty pleased with the result, tell me what you think (optional)! I've mentioned the OS earlier in this thread; DoomOS. That's why it's called DoomCalc, it's a part of DoomOS.
It would be really awesome if anyone copied this code and tested it for themselves. I would feel honored :smile.gif:
Same goes for the flax farm.. Anyone have any idea what I am missing? It looks right to me. I have updated to the v1.11 in hopes that the bundled cable issue would fix my problem, but no luck.
I was hoping for something built into the computer itself, much like all the other programs here.
@streetsstar5
to get a color value on a bundled cable just use 2^ (whatever power) to get the number (i.e 2^3 = 8; 2^4 = 16, etc). But also he has set it up even easier. Use rs.setBundledOutput("<side>", colors.<colorname>) where <side> is naturally which side of the computer and <colorname> is one of the 16 different colors. The same applies to getting an incoming color.
Then ask a question or contribute something maybe? Speaking of, I have yet to see my question answered.
I haven't made anything new to contribute yet but I'm working on it
Here's my code: http://pastebin.com/pkYZPuLr
I'm getting an "Index expected, got nil" error, and I'm not sure why.
Part of me wishes there was a "ln:#" part in there, so I knew what line the error was caused by.
Functions: It's an actually decent calculator.
Code: http://pastebin.com/C68PEiec
Description:
It's a calculator that can actually parse expressions.
You know all those ones that ask you "Do you want to add, subtract, multiply or divide? What's the first number? What's the second number?"? It's not that.
Example transcript, what I typed is in italics.
List of functions:
List of constants:
Put os.shutdown() after print("Pumps shut down")
That would make the computer shut down. It would not make the pumps shut down.
Also what you could do is type
and replace the things in brackets with the appropriate thing but the first and second [side] must be the same side.
This would check whats on and add the color you want to it or you could replace the + with a - to remove the color.
Name of program: DoomCalc
Functions: Math (+ - * /)
Download link/Copy of code:
A description: A basic calculator with fairly advanced UI that I made for my "operating system". I'm pretty pleased with the result, tell me what you think (optional)! I've mentioned the OS earlier in this thread; DoomOS. That's why it's called DoomCalc, it's a part of DoomOS.
It would be really awesome if anyone copied this code and tested it for themselves. I would feel honored :smile.gif:
How dare you beat me! :tongue.gif:
O_o what? I started and couldn't keep up so I made the forum.
: ) what did you have in mind? and how did you like the circuit API?