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

Missile Control Script, Help Please

Started by Kadecamz, 28 July 2012 - 11:44 PM
Kadecamz #1
Posted 29 July 2012 - 01:44 AM
ty for helping.
Though I need to know how to hook the program up to the monitor when it runs.






conventinal = ("1337")

heavy = ("2448")

print ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES")

if = conventinal then
rs.setOutput (left, true)

if = heavy then
rs.setOutput (right, true)

end

print("Launching!")

sleep(5)
print("Action Completed (Assuming the code is correct")
sleep(5)
os.shutdown()


Thats the code.

Its coded so that it'll have two signal senders from Wireless Redstone and it'll go to my my missile panel, which will launch the missiles.

But please tell me why the script won't work.
ty
brett122798 #2
Posted 29 July 2012 - 01:50 AM
Found 6 errors, new code:


conventinal = ("1337")

heavy = ("2448")

print ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES")
input = read()

if  input == conventinal then
rs.setOutput ("left", true)

elseif input == heavy then
rs.setOutput ("right", true)

end

print("Launching!")

sleep(5)
print("Action Completed (Assuming the code is correct)")
sleep(5)
os.shutdown()
Kadecamz #3
Posted 29 July 2012 - 01:52 AM
TY.
I'm not one of those people that can make scripts with functions without making a small error sometimes.
brett122798 #4
Posted 29 July 2012 - 01:54 AM
TY.
I'm not one of those people that can make scripts with functions without making a small error sometimes.
Functions are fairly easy:


function funcname()
<Code>
end

funcname()

Btw, I edited my last post, found a 5th error if you didn't see.
Kadecamz #5
Posted 29 July 2012 - 01:55 AM
Uh, when I use that code I get "bios:206: [string "startup" ]: 7 : unexpected symbol
brett122798 #6
Posted 29 July 2012 - 01:56 AM
6th error! Just keep on finding them, lol.
MysticT #7
Posted 29 July 2012 - 01:56 AM
You never get the input, so you don't have something to compare with. Try with this:

local conventinal = "1337"
local heavy = "2448"

print("ENTER CODE FOR THE HEACY OR CONVENTINAL MISSILES")
local input = read()

if input == conventinal then
  rs.setOutput("left", true)
elseif input == heavy then
  rs.setOutput("right", true)
end

print("Launching!")
sleep(5)
print("Action Completed (Assuming the code is correct)")
sleep(5)
os.shutdown()
Xenthera #8
Posted 29 July 2012 - 01:59 AM
Just some small errors, I would've posted the new code but it's already been done.
Kadecamz #9
Posted 29 July 2012 - 02:04 AM
TY.
you can't expect an 11 year old to know how to always code.
brett122798 #10
Posted 29 July 2012 - 02:06 AM
TY.
you can't expect an 11 year old to know how to always code.
I'm 13 and I'm fluent-ish.
Kadecamz #11
Posted 29 July 2012 - 02:07 AM
BTW.
How do I make it so that it'll show up on the monitor I have installed?
brett122798 #12
Posted 29 July 2012 - 02:08 AM
BTW.
How do I make it so that it'll show up on the monitor I have installed?
I've never dealt with monitors so I have no clue, sorry.
Kadecamz #13
Posted 29 July 2012 - 02:09 AM
thats k.
Kadecamz #14
Posted 29 July 2012 - 04:38 AM
Testing a new code with else, can you help?


conventinal = ("1337")
heavy = ("2448")
textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
input = read()
if  input == conventinal then
rs.setOutput ("left", true)
elseif input == heavy then
rs.setOutput ("right", true)
if input == else then
textutils.slowPrint("WRONG CODE! SHUTTING DOWN IMMEDIANTLY")
os.shutdown()
end
print("Launching!")
sleep(2)
textutils.slowPrint("Action Completed ("Missiles have been launched!")
sleep(3)
os.shutdown()
Xenthera #15
Posted 29 July 2012 - 04:55 AM

conventinal = ("1337")
heavy = ("2448")
textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
input = read()
if  input == conventinal then
rs.setOutput ("left", true)
elseif input == heavy then
rs.setOutput ("right", true)
if input == else then
textutils.slowPrint("WRONG CODE! SHUTTING DOWN IMMEDIANTLY")
os.shutdown()
end
print("Launching!")
sleep(2)
textutils.slowPrint("Action Completed ("Missiles have been launched!")
sleep(3)
os.shutdown()

Change if input == else then

to

else

like this:

conventinal = ("1337")
heavy = ("2448")
textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
input = read()
if  input == conventinal then
rs.setOutput ("left", true)
elseif input == heavy then
rs.setOutput ("right", true)
else
textutils.slowPrint("WRONG CODE! SHUTTING DOWN IMMEDIANTLY")
os.shutdown()
end
print("Launching!")
sleep(2)
textutils.slowPrint("Action Completed ("Missiles have been launched!")
sleep(3)
os.shutdown()
Kadecamz #16
Posted 29 July 2012 - 04:57 AM
thanks, mate! :ph34r:/>/>
Xenthera #17
Posted 29 July 2012 - 04:58 AM
Also, if you want to run it on a monitor, enter in the computer

monitor (side) (program)

so,

monitor top testprogram

would run the program named testprogram on the top monitor.
Kadecamz #18
Posted 29 July 2012 - 05:15 AM
Yeah. I know.

But I wanna know how to have it run on both the monitor and the computer.
Kadecamz #19
Posted 29 July 2012 - 05:18 AM
BTW, does how enterkeyed your code is matter?

If it has no enters would it still work?
Kadecamz #20
Posted 29 July 2012 - 05:26 AM
WOO.
Made my first script ALL by myself without posting on help from a pro thread. :ph34r:/>/>
Laserman34170 #21
Posted 30 July 2012 - 11:13 PM
I can help with the monitors. Here is some code.

function print(text)
  monitor.print(text)
  term.write(text)
end
side = "top" --Side of monitor
monitor = peripheral.wrap(side)
-- then you just have to add this code and not change anything!
Cranium #22
Posted 31 July 2012 - 12:11 AM
Just from a proofreading standpoint: conventinal is actually properly spelled "CONVENTIONAL". Bugging me that nobody saw cause to correct it, but not a huge thing…