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

Advanced Nuclear reactor management.

Started by quinn9009, 10 September 2013 - 09:40 PM
quinn9009 #1
Posted 10 September 2013 - 11:40 PM
First things first (This is going to be a heavy request): I'm new to using Lua, and cc, but I am a pro at anything Tekkit classic ( excluding CC ). I've got a Nuclear power plant with 10 Mark V 2400 EU/T reactors, and I'd like to make a CC program to control each reactor separately from one console. I've looked at recent forums about this topic, and most don't fit the bill in terms of how many reactors there will be, or what I'd like to have for the main menu options. It should go from boot to A password menu that you enter the password from - to the Main menu and from there be able to Turn on each reactor ( when a reactor is turned on the cooling systems auto start ), a Shutdown for each reactor, Start a timer for extracting Depleted uranium cells and refueling the reactors ( all I'll need is the option to activate a redstone signal that will start a redpower timer ), an option to reroute the power from the main factory's, machines, battery, and EMC Generator to my base's mass fabricator array ( using splitter cables for the main cable turing on, and shutting off splitter cables for the line to the mass fabricator array ), a cancel and shutdown option, and an option to open or close the maintenance blast doors to go into the core.

These reactors are not a joke! They put off at-least 20,000 EU/T combined! And they also require a constant supply of Ice for the coolant, however 2 of these reactors are breeder reactors running at 330 or so Depleted Uranium cells recharged a cycle, so they don't output a ton of energy, but they do output enough energy to bump up the EU/T from 19,200 EU/T to 20,000 EU/T, the last base I had was unprepared for the reactors, and they went critical, and made a giant hole in the world!!! Please help me with this project I'd really like to one day be able to just walk into my base and spend no more than 1 minute turning on all of my reactors, and actually be able to trust that they will be fine. Oh and I'm going to use bundled cables to output signals from the back.

Thanks

~Quinn~ And remember everyone! Have Fun, Have Nukes!
Lyqyd #2
Posted 11 September 2013 - 12:38 AM
Split into new topic.

Please post your current code, or provide a more detailed set of questions to help us point you in the right direction.

As a note: If you're looking to request a program be written for you instead of seeking help with a program you're writing yourself, I can move this over to General.
quinn9009 #3
Posted 11 September 2013 - 08:22 AM
I'm sorry but I have no Idea where to even begin with writing this code, :(/> but I can provide links to download my worlds with the reactors to help get an Idea of what your dealing with :P/>

The only problem is that the reactors in my test world are a several hundred blocks away, because I was working on a prototype nuclear plant ( which exploded because I had a little too less Ice flow coming in ), and therefore when you spawn you will be above a crater, and several hundred blocks away, but I also have pics of the reactors I can post later today. Each reactor has 6 chambers, outputs at least 2400 EU/T, has two reactor cooling units from the MFFS mod (these activate automatically when the forcefield is on), a reactor area projector, two HV transformers, an output cable of glass fiber, and two filters that extract ice from energy condensers pre loaded with RM to be turned into Ice.
quinn9009 #4
Posted 11 September 2013 - 10:00 AM
So if I have nothing at all written I'll be stuck writing this on my own D: ?
Hydra #5
Posted 11 September 2013 - 10:19 AM
Creating a program like this costs time. No one is just going to spend hours writing a custom program for you. If you write one yourself and get stuck somewhere people will be happy to help.

If you're using openperipherals, just connecting a wired modem to the computer and the reactor, putting network cable between them, and right-clicking the modems to connect them should get you started.

With something like this you get the heat of that single reactor:

local reactor = peripheral.wrap("generator_0") -- replace this with whatever shows up if you right-click the reactor modem
print(reactor.getHeat())

That's all you need to do to see the heat from a single reactor if you have OpenPeripherals installed.

More info:
http://www.openperipheral.info/openperipheral/documentation/ic2/nuclear-reactor
quinn9009 #6
Posted 11 September 2013 - 12:21 PM
I just don't know how to write the coding or how any of it works :(/>

This is how far I've gotten in terms of the startup:


term.clear()
term.setCursorPos(1, 1)
print("Uranium Tech.INC")
write("Enter password: ")
input = read()

password = "Nukes"
if input == password then
print("Password was correct!")
print ()
print ("Logging in")

term.clear()
term.setCursorPos(1,1)
print ("Nuclear Reactor Control Mainframe")
print ()
print ("1. Start/Stop Reactor quad core 1")
print ("2. Start/Stop Reactor quad core 2")
print ("3. Start/Stop Breeder Reactor 1")
print ("4. Start/Stop Breeder Reactor 2")
print ("5. Start/Stop Refueling Process")
print ("6. Re-route Power to the Mass. Fab. Array")
print ("7. Re-route Power back to the main line")
print ("8. Close/Open Maintenance Blast Doors")
print ("9. Start full auto cycles")
print ("10. Activate Self destruct sequence")
print ("11. Cancel and Shutdown")



I'm going to use industrial information panels to display info like heat and cycle stuff like that :P/>

All I don't know what to do is how to make the commands work and output a red stone signal through bundled cables, loop back to the main menu, and put another menu attached to the self destruct sequence so when selected it would ask for a password before activating a redstone signal. Eventually I'd like the menu to function and look just like the one for the Nuclear reactor in this video:
Hydra #7
Posted 11 September 2013 - 12:52 PM
If you don't know how it works you'll have to learn it. We all had to. There's plenty of tutorials on the wiki, start there first. I'm getting the feeling you don't want to learn but just want a ready-made program.
Rsstn #8
Posted 11 September 2013 - 01:34 PM
As the others say, you'll need to learn this for yourself, but here's where to start:

The easiest way for you to control the reactors is to power them using a redstone current via redstone dust.
To control redstone dust adjacent to one of the sides of your computer, you can use the Redstone API:

So far you have the basics needed to keep the reactor under control automatically. In order to turn on/off the reactor manually you will need a menu (like the one in your program so far) and to be able to read user inputs. The easiest way to do this is using os.pullEvent() (more specifically os.pullEvent("key")) to read when a user presses one of the number keys related to an option in the menu.

It looks like you already know the basics that fit in between the code suggestions I've given you, so just give it a go on a single reactor. Multiple reactors will be a bit tougher because if each one uses two sides of the computer for inputs/outputs, you will soon run out of sides! You'll have to find a solution to this at a later date, but for the moment, start simple! This is a pretty complex starter project so don't make it any harder than it already is. You can always make it look good at the end, once it's working!

If you get stuck with anything, just ask!
quinn9009 #9
Posted 11 September 2013 - 02:52 PM
I'd like to learn, I'd be more than happy to, but time is of the essence to me, I have little to no time ever online, I mostly do my building in Single Player Offline, and when I get the chance I play on the server Retribution Gaming.net on Tekkit Classic. But however I do have ways to download video's and watch them later. And copy and paste written tutorials, if you could please give me a link to the page about how to add a function to a command I'd be more than appreciative.

Thanks :)/>
Rsstn #10
Posted 11 September 2013 - 02:57 PM
how to add a function to a command

Sorry, I don't quite understand what you mean by that, can you explain again in a different way what you need explaining?
quinn9009 #11
Posted 11 September 2013 - 03:24 PM
I don't understand how to select a command from the list and make it work. In other words I don't know how to code it to where I can select an option press a button and turn on or off a redstone signal. I'm going to use bundled cables, I've got all the wiring down, It's just how messy it is, I could just wire everything up to a single switch and use that, but I like to keep things nice and neat ( I usually play on a laggy old computer that only goes up to 40 FPS max! ), but my real laptop will be out of the repair shop soon :D/>

But back to the subject I'm perfectly content with switches and such, but I wanted to upgrade my facility control to be controlled from one place instead of multiple places. All the computer will really do is activate red power bundled cables and deactivate cables through the back, oh and one more question where is the os.pull code supposed to go? and what are variables? :/
Hydra #12
Posted 11 September 2013 - 05:55 PM
But back to the subject I'm perfectly content with switches and such, but I wanted to upgrade my facility control to be controlled from one place instead of multiple places. All the computer will really do is activate red power bundled cables and deactivate cables through the back, oh and one more question where is the os.pull code supposed to go? and what are variables? :/

Stuff like that is incredibly basic. Programming is something you have to learn yourself. If you get stuck people can help you, but no one can help you if you don't put in the effort. And if you don't have the time, simply don't do it!

There's no instant gratification in programming, not even Lua. It's hard work to get somewhat decent at it. There's a reason why after 4 years of university software engineers are still 'junior'.
quinn9009 #13
Posted 11 September 2013 - 05:58 PM
I mean I've had some experience, and I am a fast learner, but yeah I guess your right. I'll do some work on it and test it tomorrow night, then Friday I'll post if I need any help. Thanks anyways :)/>
quinn9009 #14
Posted 12 September 2013 - 08:20 AM
Ok, I've found some code from another post: local function subMenu()
while true do
clearTheScreen()
printTheSubMenu()
e, p = os.pullEvent()
if e == char then
if p == someChar then
performAction()
elseif p == goBackChar then
return
end
end
end
end

while true do
clearTheScreen()
printTheMenu()
e, p = os.pullEvent()
if e == char then
if p == someKey then
doSomeStuff()
elseif p == subMenuKey then
subMenu()
elseif p == exitChar then
return
else
whineAboutInvalidOption()
end
end
end
So is this what I need for the code for each menu?
Hydra #15
Posted 12 September 2013 - 10:23 AM
You need to understand code, not 'find and copy-paste it'. If you would have understood any lua you would have seen that the above does not work at all. Again you've done nothing to actually understand programming.
quinn9009 #16
Posted 12 September 2013 - 11:13 AM
Well I'm sorry I don't know anything on how lua works! D:

But I do have some code I've written down, I'm not sure if it works though :/

From what I've read in other posts and from the wiki I'm 60% sure I'm missing some stuff in this code :(/>


term.clear()
term.setCursorPos(1, 1)
print("Uranium Tech.INC")
write("Enter password to access controls: ")
input = read(“*”)
if password == “DarkDeath” then
print(“Correct Password user, accessing control mainframe”)
else
print(“Incorrect!”)
sleep (2)
os.reboot ()

term.clear()
term.setCursorPos(1,1)
print ("Nuclear Reactor Control Mainframe")
print ()
print ("1. Start Reactor quad core 1 - Press 1")
print ("2. Start Reactor quad core 2 - Press 2")
print ("3. Start Breeder Reactor 1 - Press 3")
print ("4. Start Breeder Reactor 2 - Press 4")
print (“5. Stop Reactor quad core 1 - Press 5”)
print (“6. Stop Reactor quad core 2 - Press 6”)
print (“7. Stop Breeder Reactor 1 - Press 7”)
print (“8. Stop Breeder Reactor 2 - Press 8”)
print ("9. Start and Stop Refueling Process - Press 9”)
print ("10. Re-route Power to the Mass. Fab. Array - Press q”)
print (“11. Re-route Power to the Main line - Press w”)
print ("11. Close/Open Maintenance Blast Doors - Press e”)
print ("12. Start/Stop full auto cycles - Press r”)
print ("13. Activate Self destruct sequence - Press t”)
print ("14. Cancel and Shutdown - Press y”)



e,p = os.pullEvent()

if e == “char” then

if p == "1" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Starting Reactor quad core 1…")

sleep(2)

redstone.setBundledOutput("back", 1)

sleep(2)

redstone.setBundledOutput("back", 0)

print ()

print (" Reactor quad core 2 Successfully Started")

return

elseif p == "2" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Starting Reactor quad core 2…")

sleep(2)

redstone.setBundledOutput("back", 2)

sleep(2)

redstone.setBundledOutput("back", 0)
print ()

print (" Reactor quad core 2 Successfully Started")

return

elseif p == "3" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Starting Breeder Reactor 1…")

sleep(2)

redstone.setBundledOutput("back", 4)

sleep(3)

redstone.setBundledOutput("back", 0)
print ()

print (" Breeder Reactor 1 Successfully Started")

return

elseif p == "4" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Starting Breeder Reactor 2…")

sleep(2)

redstone.setBundledOutput("back", 8)

sleep(2)

redstone.setBundledOutput("back", 0)
print ()

print (" Breeder Reactor 2 Successfully Started")

return

if p == "5" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Stopping Reactor quad core 1…")

sleep(2)

redstone.setBundledOutput("back", 1)

sleep(2)

redstone.setBundledOutput("back", 0)

print ()

print (" Reactor quad core 2 Successfully Stopped")

return

elseif p == "6" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Stopping Reactor quad core 2…")

sleep(2)

redstone.setBundledOutput("back", 2)

sleep(2)

redstone.setBundledOutput("back", 0)
print ()

print (" Reactor quad core 2 Successfully Stopped")

return

elseif p == "7" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Stopping Breeder Reactor 1…")

sleep(2)

redstone.setBundledOutput("back", 4)

sleep(3)

redstone.setBundledOutput("back", 0)
print ()

print (" Breeder Reactor 1 Successfully Stopped")

return

elseif p == "8" then

term.clear()

term.setCursorPos(1,1)

print ("Loading Mainframe…")

sleep(3)

print ()

print ("Loading Subsystems…")

sleep(2)

print()

print ("Stopping Breeder Reactor 2…")

sleep(2)

redstone.setBundledOutput("back", 8)

sleep(2)

redstone.setBundledOutput("back", 0)
print ()

print (" Breeder Reactor 2 Successfully Stopped")

return

elseif p == “9”

term.clear()

term.setCursorPos(1,1)

print ("Starting Refueling Process”)

print ()

sleep (2)

print (“Please standby this process will take 2.5 minutes”)

redstone.setBundledOutput("back", 16)

sleep (150)

redstone.setBundledOutput("back", 0)

print ()
print (“Reactors refueled”)

sleep (2)

return

elseif p == “q”

term.clear()

term.setCursorPos(1,1)

print ("Rerouting Power from main line to Mass Fab. Array…”)

redstone.setBundledOutput("back", 32)

sleep (3)

redstone.setBundledOutput("back", 0)

print ()

print (“Power rerouted”)

sleep (3)

return

elseif p == “w”

term.clear()

term.setCursorPos(1,1)

print ("Rerouting Power back to the main line”)

redstone.setBundledOutput("back", 32)

sleep (3)

redstone.setBundledOutput("back", 0)
print ()

print (“Re-routed power”)

sleep (3)

return

elseif p == “e”

term.clear()

term.setCursorPos(1,1)

print ("Opening, or closing Blast doors”)

redstone.setBundledOutput("back", 64)

sleep (3)

redstone.setBundledOutput(“back”, 0)

print ()

print (“Done :P/>”)

return

elseif p == “r”

term.clear()

term.setCursorPos(1,1)

print ("Starting or stopping fully automatic cycles”)

print ()

redstone.setBundledOutput("back", 128)

sleep (3)

redstone.setBundledOutput(“back”, 0)

print (“Done :P/>”)

return

elseif p == “t”

term.clear()

term.setCursorPos(1,1)

print ("You have 2 minutes to vacate the area!!!”)

sleep (120)

redstone.setBundledOutput("back", 256)

sleep (3)

redstone.setBundledOutput(“back”, 0)

return

elseif p == “y”

term.clear()

term.setCursorPos(1,1)

print ("Shutting down. . .”)

os.shutdown ()
campicus #17
Posted 12 September 2013 - 11:55 AM
Hey mate. Your obviously new so here are a few tips for using the forums :)/>

1. As other people have mentioned, people here will look at code you make and help you out fixing errors you cannot fix. What people will not do is make a program for you or go through a massive amount of your code when you say "it doesn't work" or "can someone check this". If you get an error, post the code and the error.

2. If you want to post code use pastebin.com. Don't post a huge amount of code on the forum, it makes things messy and difficult to read. You are less likely to get help.

3. If you don't use pastebin, use spoilers [spoiler.]<your spoiler here>[/spoiler.] (without the " . "s) and code [code.]<your code here>[/code.] (without the " . "s) tags.

If you don't have time to learn computercraft either don't use it or ask in the general forum for someone to make. Maybe you will get lucky?

EDIT: Oh, and format your code (with indents), e.g.,

Spoiler

local chances = 0
local formatting = "correct"

function correctFormat()
	print("People help me because this is easy code to read!")
	sleep(1)
	if formatting == "correct" then
		chances = "high"
	else
		chances = "slim"
	end
end

while true do
	correctFormat()
	sleep(0)
end
quinn9009 #18
Posted 12 September 2013 - 12:22 PM
Sorry, I'm felling kinda sick today :(/>
And I got a terrible headache so I'm having a tough time even typing this, I'm just asking if the code is in the right format and if there are anythings than need fixed, Thanks for the tip though :)/>

I'm testing the code tonight though, I just wanted a heads up on if there are any errors before I try it.


Thanks :)/>
quinn9009 #19
Posted 12 September 2013 - 04:12 PM
Just found a youtube video series to help me learn programming :D/>

Here's a link to the video :P/>

http://www.youtube.com/watch?annotation_id=annotation_84796&feature=iv&src_vid=xnF6k2J8Xk0&v=H5a7S4eF7zw
Lyqyd #20
Posted 12 September 2013 - 05:08 PM
You need to understand code, not 'find and copy-paste it'. If you would have understood any lua you would have seen that the above does not work at all. Again you've done nothing to actually understand programming.

It's pseudo-code I used at one point to explain a better way of structuring a series of menu functions. Context is important.
campicus #21
Posted 12 September 2013 - 08:03 PM
Those tutorials will help you heaps!
quinn9009 #22
Posted 13 September 2013 - 10:12 AM
I tested some of the code last night, but I fell asleep before I got done. I also had to rewrite most of it :(/>

But here it is, also I kept getting this error about needing a = in a line near the bottom that I commented on.

[spoiler.]
term.clear()
term.setCursorPos(1, 1)
print("Uranium Tech.Inc")
write("Enter password to access controls: ")
input = read("*")
if password == DarkDeath then
print("Correct password user, accessing control mainframe")
end
term.clear()
term.setCursorPos(1, 1)
print("Nuclear Reactor Control Mainframe")
print()
print("1. Start Reactor quad core 1 - Press 1")
print ("2. Start Reactor quad core 2 - Press 2")
print("3. Start Breeder Reactor 1 - Press 3")
print("4. Start Breeder Reactor 2 - Press 4")
print("5. Stop Reactor quad core 1 - Press 5")
print("6. Stop Reactor quad core 2 - Press 6")
print("7. Stop Breeder Reactor 1 - Press 7")
print("8. Stop Breeder Reactor 2 - Press 8")
print("9. Start and Stop Refueling Process - Press 9")
print("10. Re-route Power to the Mass. Fab. Array - Press q")
print("11. Re-route Power to the Main line - Press w")
print("12. Close/Open Maintenance Blast Doors - Press e")
print("13. Start/Stop full auto cycles - Press r")
print("14. Activate Self-destruct sequence - Press t")
print("15. Cancel and Shutdown - Press y")
eof
e,p== os.pullEvent() = - This line
if e == "char" then - and this line have been giving me problems :(/>, it says I need a = sign some where in here and I tried putting it everywhere and it still didn't fix it D:
if p == "1" then
term.clear()
term.setCursorPos(1,1)
print("Loading Mainframe…")
sleep(3)
print()
print("Loading Subsystems…")
sleep(2)
print()
print("Starting Reactor quad core 1…")
sleep(2)
redstone.setBundledOutput("back", 1)
sleep(2)
redstone.setBundledOutput("back", 0)
print()
print(" Reactor quad core 2 Successfully Started")
end
return[/spoiler.]

Spoiler! Y U NO WORK?!?!?
quinn9009 #23
Posted 13 September 2013 - 10:16 AM
But instead of using this to boot up my cc computer I decided to make a program that would run it instead, after an hour of trying to get this to work for the startup I decided to give up :(/>
Yevano #24
Posted 14 September 2013 - 10:10 PM
Spoiler! Y U NO WORK?!?!?

Take off the dots inside your tags. And use code tags for code, or code tags surrounded by spoilers if it's a large amount of code.
campicus #25
Posted 14 September 2013 - 10:14 PM
But instead of using this to boot up my cc computer I decided to make a program that would run it instead, after an hour of trying to get this to work for the startup I decided to give up :(/>

Use:


shell.run("<yourProgramHere>")
quinn9009 #26
Posted 15 September 2013 - 10:49 AM
ok thanks :)/>
kreezxil #27
Posted 15 September 2013 - 08:03 PM
Man your code is jacked up, I'll throw you a meat bone, but you really need to try out more lua tutorials.

Spoiler

-- You use the following so much it should be put in a function

function wipeScreen()
   term.clear()
   term.setCursorPos(1, 1)
end

-- first call to your function
wipeScreen()
print("Uranium Tech.Inc")
write("Enter password to access controls: ")
-- input = read("*")
-- below you are checking password but here you are calling the variable input, guaranteed bug!
-- instead try
password = read("*")

--[[
if password == DarkDeath then -- this won't work you need the part after the == in quotes, ie == "DarkDeath"
print("Correct password user, accessing control mainframe") -- pointless cause you are not failing other passwords
end
]]

-- probably you meant it to look like the following
if password ~= "DarkDeath" then
   print("Unauthorized Access! Reactor Meltdown Emminent!")
   return -- we're not gonna blow up anything unless you want too! just leave the program
else
   print("Well Done Master! You've remembered your password after a night of binge drinking!")
end -- see what we did here?

print("Press any key to continue")
_,_ = os.pullEvent("char") -- we don't care about any variable just want a key to be pushed.

wipeScreen() -- self-document function name at work. yay!

print("Nuclear Reactor Control Mainframe")
print()
print("1. Start Reactor quad core 1 - Press 1")
print ("2. Start Reactor quad core 2 - Press 2")
print("3. Start Breeder Reactor 1 - Press 3")
print("4. Start Breeder Reactor 2 - Press 4")
print("5. Stop Reactor quad core 1 - Press 5")
print("6. Stop Reactor quad core 2 - Press 6")
print("7. Stop Breeder Reactor 1 - Press 7")
print("8. Stop Breeder Reactor 2 - Press 8")
print("9. Start and Stop Refueling Process - Press 9")
print("10. Re-route Power to the Mass. Fab. Array - Press q")
print("11. Re-route Power to the Main line - Press w")
print("12. Close/Open Maintenance Blast Doors - Press e")
print("13. Start/Stop full auto cycles - Press r")
print("14. Activate Self-destruct sequence - Press t")
print("15. Cancel and Shutdown - Press y")
--eof --wtf? what is this?

--[[
see http://computercraft.info/wiki/OS_(API) for details on how to use the events.
]]

-- since all you want is the "char" event, make this simple on yourself and use
_, key = os.pullEvent("char")
-- since you are targeting char event you don't need that event variable and you can toss it with _
-- also call your variables meaningful names so it is easier to debug your program
-- longer variable names and function names help you create what is called
-- self-documenting code, combined with comments people will be to help you better and you can
-- always return and pick up where you left off.

-- instead of
-- e,p== os.pullEvent() = - This line

-- see now here we run into that part where you really need to understand code
-- because you see the input
-- if e == "char" then
--[[ and this line have been giving me problems :(/>/>, it says I need a = sign some where in here and I tried putting it everywhere and it still didn't fix it D:
]]
-- that's because it was complaining about your hordes of other bugs but you didn't realize it.
   -- if you use my pullEvent you don't need this "if e ==" thing
   if key == "1" then
	  -- so you should be testing against key if you use my example, even so all of the below
	  -- is just for reactor 1, you'll have to repeat the tests for each of the options in your menu
	 wipeScreen()
	 print("Loading Mainframe...")
	 sleep(3) -- even one second is a long time try smaller values
	 print()
	 print("Loading Subsystems...")
	 sleep(2) -- same here
	 print()
	 print("Starting Reactor quad core 1...")
	 sleep(2) -- weee, i'm on a roller coaster!
	 redstone.setBundledOutput("back", 1)
	 sleep(2) -- why? what's the precedent for these?
	 redstone.setBundledOutput("back", 0)
	 print()
	 print(" Reactor quad core 2 Successfully Started")
-- really? how do you know? I don't see you reading it's output.
end

-- I suggest taking all the stuff for option 1 and jamming it into a function say maybe call it function startReactor()
-- and then pass the reactor number to it, that way you can reuse the code without making your program
-- unnecessarily long.
-- btw, the end above was for the second if not the first, the first if was missing an end and also would've thrown you an error
-- but since you don't need the first if you can leave it out and not worry about the second end
-- you need to study up on if-then-elseif-else-end blocks.
--return --unnecessary, only useful inside of lua chunks.

-- your challenge btw is to learn from my own noobish code, rip out all the comments and progress a little further.
-- put your own comments in all over the place so you will know what you are doing.

Oh? Do I know if any of that above will work? Sure I do.

Link to pull it into computer craft is http://pastebin.com/LundLsQ0
quinn9009 #28
Posted 16 September 2013 - 08:08 AM
Thanks man :D/>
I've been sick with strep throat for the last three days :(/>, but thanks for the help :D/>
Every little bit helps me get closer to making this program :)/>

Thanks, ~Quinn~
kreezxil #29
Posted 16 September 2013 - 09:42 AM
No problem.
quinn9009 #30
Posted 16 September 2013 - 06:50 PM
I just fixed the code so it would work, is this what it should look like kreezxil?
SpoilerNew experimental code:






function wipeScreen()
term.clear()
term.setCursorPos(1, 1)
end - this all needs to be put in the function, I’ll call it wipe1

wipe1 - Code begins here
print(“Black Fortress Industries”)
write(“Enter password to access the control menu, user”)
password = read(“*”)
if password ~= “DarkDeath” then - but if this is the password then why does this deny access?
print("Unauthorized Access!”)
return
else
print(“Welcome user”)
end
- not sure if I need a space here
print(“Press any key to continue”)
_,_ = os.pullEvent("char")

wipeScreen()

print("Nuclear Reactor Control Mainframe")
print()
print("1. Start Reactor quad core 1 - Press 1")
print ("2. Start Reactor quad core 2 - Press 2")
print("3. Start Breeder Reactor 1 - Press 3")
print("4. Start Breeder Reactor 2 - Press 4")
print("5. Stop Reactor quad core 1 - Press 5")
print("6. Stop Reactor quad core 2 - Press 6")
print("7. Stop Breeder Reactor 1 - Press 7")
print("8. Stop Breeder Reactor 2 - Press 8")
print("9. Start and Stop Refueling Process - Press 9")
print("10. Re-route Power to the Mass. Fab. Array - Press q")
print("11. Re-route Power to the Main line - Press w")
print("12. Close/Open Maintenance Blast Doors - Press e")
print("13. Start/Stop full auto cycles - Press r")
print("14. Activate Self-destruct sequence - Press t")
print("15. Cancel and Shutdown - Press y")

_, key = os.pullEvent("1") - I changed the key that needs pressed from char to 1
wipeScreen()
print("Loading Mainframe…")
sleep(1)
print()
print("Loading Subsystems…")
sleep(1) – same here
print()
print("Starting Reactor quad core 1…")
sleep(1)
redstone.setBundledOutput("back", 1)
sleep(2)
redstone.setBundledOutput("back", 0)
print()
print(" Reactor quad core 1 Successfully Started") - Fixed 2 and changed the # to 1
return - I'm not sure if this would do it, but I'd like this to return to the main menu after doing this.

I was also thinking of putting this in a function like you suggested, I just wanted you to take a look at it first.
P.S. This is all the code from your post up there I just want some clarification on some marked stuff around the page, and keep in mind I'm using Tekkit Classic CC (1.2.5) not Minecraft 1.6 CC. so are you sure this is right? :P/>
kreezxil #31
Posted 16 September 2013 - 07:38 PM
You would not use return for going back to the main menu, what you need to do is use a loop around it all. If we are going to come back to the menu forever then forevever loop will work perfectly, for the start of your loop use
while true do
and at the end of all of the master code that gets repeated and which will signify the end of the loop put
end
.

Now, I'm not sure what you mean by
wipe1 - Code begins here
because you don't have a line indicating where it ends either, also, this line is not a comment so it'll definitely throw an error and since it appears to be a note to yourself put
--
right in front of it so that it'll register as a comment.

Also, are you not reading anything the others and I have told you to go read? You can't change os.pullEvent("char") to os.pullEvent("1") because that is not a valid event, "char" is a valid event as is "key" and a few others, all of which you would know if you had gone to www.computercraft.info, clicked on the wiki, then "apis" and finally "os". Find the command you are using, click it and get all the pertinent usages on it. Scroll further down and you'll get a list of the valid events that you can jam in between the parens.
() -- parens, one of which is called a parenthesis
.

And to knock it off, you technically broke what I wrote you as you removed the huge if block that tested to see what key got pressed. As far as the differences between 1.25 and 1.5x of computercraft, I'm not sure but I think it has something to do with a concept that is light-years beyond where you are at the moment and is therefore non-consequential. Also, why are you holding yourself back, join a server that is more current. There a plenty to choose from in the "servers" forum of which mine is there. You'll have to read to find it tho.
quinn9009 #32
Posted 16 September 2013 - 08:31 PM
Sorry, I'm just trying to understand Lua, and how I can make the program I wanted to make :(/>

I'll revise the code tomorrow, and I can test it thursday :P/>

But for now good night :P/>

P.S. By code starts here I meant for that to be a note and therefore not part of the code :P/>
Bubba #33
Posted 17 September 2013 - 06:46 AM
How is it that no one has mentioned the PIL or Lua-users wiki?

OP, you should definitely give one of the above links a go. That's where a lot of people learned how to write good Lua code, and it is the most accurate source of information. Videos can often be misleading (particularly for the more basic stuff) and, if you're pressed for time, are not a good source of information. The PIL (Programming in Lua) is an especially good reference because it is the official source of information, is very well written, and is organized logically.
quinn9009 #34
Posted 17 September 2013 - 08:02 AM
Thanks man :D/>
I'll check it out here in a bit :)/>, but for now I got some stuff to go to here in a bit :P/>


"Whoever does not miss the Soviet Union has no heart. Whoever wants it back has no brain."

— Vladimir Putin
quinn9009 #35
Posted 17 September 2013 - 10:47 AM
So how do I customize the key input so I can press 1 and have the first option run? ( where do I put this line of code to allow the first option to be run by pressing 1 on the key board? ) The notes are in black.


if 1 == “char” then - Here is the part that makes no sense to me, I don't understand where this line of code is supposed to go after the line of code below
_, key = os.pullEvent("char") - this line of code, this is the one you wrote up kreezxil
kreezxil #36
Posted 17 September 2013 - 02:30 PM
Yes it is, think about what you are doing. You really need to learn programming structures, all of your questions are indicative of your ignorance in programming. Programming is a lot like a grocery list, daily agenda or instruction manual. But more so it is most like those adlib books you can buy for a buck at the dollar store. Since I want you to learn how to program I will write some new code for you with even more elite stuff in comments. Read all the comments. You should be writing this stuff down in a notebook somewhere. It is then up to you to follow the links that Bubba gave you to figure them out. You really have to learn this stuff if you want to program. There is no short cut. On a side note I'll write the whole program for you for $100, if interested I will give you my Paypal instructions, once payment is received I'll write it and you won't have to lift a finger. Now hopefully some kind soul will see what I did right there and write the whole program for free for you. You can only hope.

Now on with the lesson …

You need to study these points as they will help you immensely:
  1. These links really will help you to learn lua please don't shows us your ignorance again by not reading them and following their tutorials: http://computercraft.&#46;&#46;/wiki/Main_Page, http://www.locofilm.co.uk/LuaCow/, http://www.lua.org/pil/contents.html, and Lua-users wiki
  2. As Lyqyd made clear to me in IRC chat (you should check that out too btw), all variables created outside of your functions should be implicitly declared as local at the top of your program.
  3. As I have made clear, repetitive code should be either put in a function or loop or both as deemed necessary.
  4. I did not mention this before, but your program should be as elegant as possible. That means not having unnecessary code. The way you achieve that is by looking at it constantly while remembering to always review #1, #2 and #3 (I do this all the time), and hammer out a newer more optimized piece of code.
*CODE Update 9/20/2013
Now for the rewrite:
Spoiler
-- implicitly localize and initialize variables that outside of functions
local password, key = "",""

-- setup your functions that contain code you wish to reuse
function startReactor(type,unit,bundleColor)
  -- type will be either "breeder" or "quad core"
  -- unit is its unit designation number
  -- bundleColor is the numerical value of the colors needed to activate the redstone to turn on the reactor
     wipeScreen()
     delayPrint(3,"Loading Mainframe...")
     print()
     delayPrint(2,"Loading Subsystems...")
     print()
     if type == "breeder" then
      delayPrint(2,"Starting Breeder Reactor " .. unit .. "...")
     else -- maybe we don't want to chain an if but want instead a failsafe execution if the above test is false
        delayPrint(2,"Starting Reactor Quad Core " .. unit .. "...")
     end
     redstone.setBundledOutput("back", bundleColor)
     sleep(2)
     redstone.setBundledOutput("back", 0)
     print()
     print(" Reactor quad core 1 Successfully Started") 
     if type == "breeder" then
      delayPrint(2,"Breeder Reactor " .. unit .. " Successfully Started")
     else 
        delayPrint(2,"Reactor Quad Core " .. unit .. " Successfully Started")
     end
end -- the end of the function

function wipeScreen()
   term.clear()
   term.setCursorPos(1, 1)
end

function delayPrint(pause,msg)
   print(msg)
   sleep(pause)
end

function getKey(prompt)
  local key = "" -- not the same as the other key outside the function
  print(prompt)
  _, key = os.pullEvent("char") -- char is an event that occurs when keyboard key is pressed
  return key -- send key back as value to the calling line for assignment or processing
end

-- functions shouldn't be defined after this point as what is below is the main body of the program

wipeScreen()
print("Uranium Tech.Inc")
write("Enter password to access controls: ")
password = read("*")

if password ~= "DarkDeath" then
   print("Unauthorized Access! Reactor Meltdown Emminent!")
   return -- if you don't type the right password this line shoots back out of the program
else
   print("Well Done Master! You've remembered your password after a night of binge drinking!")
   -- but you did so it keeps you in the program
end 

_ = getKey("Press any key to continue.") -- if we don't do this no one will see the success message above.


-- now let's start that forever loop I told you about

while true do -- you see true is always true so the loop keeps running

   wipeScreen()

   print("Nuclear Reactor Control Mainframe")
   print()
   print("1. Start Reactor quad core 1 - Press 1")
   print ("2. Start Reactor quad core 2 - Press 2")
   print("3. Start Breeder Reactor 1 - Press 3")
   print("4. Start Breeder Reactor 2 - Press 4")
   print("5. Stop Reactor quad core 1 - Press 5")
   print("6. Stop Reactor quad core 2 - Press 6")
   print("7. Stop Breeder Reactor 1 - Press 7")
   print("8. Stop Breeder Reactor 2 - Press 8") 
   print("9. Start and Stop Refueling Process - Press 9")
   print("10. Re-route Power to the Mass. Fab. Array - Press q")
   print("11. Re-route Power to the Main line - Press w")
   print("12. Close/Open Maintenance Blast Doors - Press e")
   print("13. Start/Stop full auto cycles - Press r")
   print("14. Activate Self-destruct sequence - Press t")
   print("15. Cancel and Shutdown - Press y")

   key = getKey("Your command?")
   if key == "1" then
      startReactor("quad",1,colors.red)
   elseif key == "2" then
      startReactor("quad",2,colors.cyan)  
   elseif key == "3" then
      startReactor("breeder",3,colors.magenta)
   elseif key == "4" then
      startReactor("breeder",4,colors.green)
   end -- stop testing key for now

end -- this is the other side of the forever loop when cc sees this it shoots back to the line containing the "while"

--[[ I see now why the others didn't want to throw you a bone and are leaving the thread alone. They are teaching me a lesson in compassion. I am feeling abused here. ]]

P.S. This is the last time I'll write any code for you until you either pay me, find someone else to do it cheaper or for free or learn to code on your own.

pastebin: http://pastebin.com/LundLsQ0
pastebin code: LundLsQ0
Edited on 20 September 2013 - 11:19 AM
quinn9009 #37
Posted 17 September 2013 - 02:58 PM
Thanks kreezxil, sorry but I just wanted help with that question, not writing all the program :P/>
So nope I'm not asking for someone to write the program, just asking for help :P/>
P.S. I'm not that in need to pay $100 for someone to write some code for me if I only need help on some of it, but thanks for the help :)/>

Oh and before I forget again: "Whoever does not miss the Soviet Union has no heart. Whoever wants it back has no brain."
— Vladimir Putin
quinn9009 #38
Posted 17 September 2013 - 03:54 PM
And thanks soooooooo much :D/>
I hope I haven't been acting like a jerk or a noob to you guys, but I will offer this: If you ever see a guy on any minecraft based game, FTB, Tekkit, Hexxit, vanilla, ect, by the name of quinn9009 and you need help building any structure or very efficient factory, or redstone contraption, or just need something excavated or built just message me (quinn9009) and I'll help :)/>

I'm a minecraft redstone engineer/expert, and one of the best at making very efficient, laggless and completely automated factories :)/>
kreezxil #39
Posted 17 September 2013 - 05:02 PM
I'm a minecraft redstone engineer/expert, and one of the best at making very efficient, laggless and completely automated factories :)/>

Do you have any videos to back that up?
quinn9009 #40
Posted 17 September 2013 - 05:03 PM
Nope but I can give world downloads :D/>
kreezxil #41
Posted 17 September 2013 - 06:02 PM
You should make videos, it'll really help people that want to learn from others such as yourself.
quinn9009 #42
Posted 18 September 2013 - 12:42 PM
Here's a link to a forrum where I posted all about my factories :P/>, tomorrow I'll give a download link for my survival world with the actual 3x speed HV Solar Array Factory (It makes 1 HV solar every 2.5 minutes) :D/>

http://www.retributiongaming.net/forum/m/11151590/viewthread/6674525-micro-factorys/page/1

Is this proof enough I'm great at making super efficient factory's kreezxil?
kreezxil #43
Posted 18 September 2013 - 02:33 PM
Here's a link to a forrum where I posted all about my factories :P/>/&amp;gt;/&amp;gt;, tomorrow I'll give a download link for my survival world with the actual 3x speed HV Solar Array Factory (It makes 1 HV solar every 2.5 minutes) :D/>/&amp;gt;/&amp;gt; http://www.retributi...factorys/page/1 Is this proof enough I'm great at making super efficient factory's kreezxil?

You are not proving anything to me. All I suggested was that you should make videos.

P.S. Are you saying that your handle there is Viktor?
quinn9009 #44
Posted 19 September 2013 - 09:38 AM
My account name is :P/>
My Minecraft IGN is quinn9009, but I prefer to be called Victor.

If I'm not proving anything then you haven't downloaded the world and checked it out :(/>
kreezxil #45
Posted 19 September 2013 - 01:00 PM
What I mean is you don't have anything to prove to me. I believe it that you have done what you have said you have done. I myself and countless others on Youtube enjoy and use Youtube videos to learn how to duplicate what others have done. While you might never be as as popular as Sethbling, Monkeyfarm, The Yogscast crew, Ant Venom or countless others, your videos should you make them will be eventually used by someone to create their own version of said demonstrated items. I have made a few, I have minor viewage at the moment but for the few that have comment through the various methods by which to do so the the feedback has been quite supportive and positive.

That is the only reason I suggested you make videos, not to prove anything to me but to share your knowledge with the rest of the world. The simple matter is not all of us, maybe not many of us have a desire to download a world to test it out. File size is a huge factor in that. For instance in my case I'm allowed 250GiB of data transfer each month before my internet provider charges me an overage fee of $1 per gb exceeding that. So If I were in the habit of downloading other peoples worlds I could easily exceed that cap and be in a world of hurt quite quickly financially. To me a Video is allot better demonstration of ones abilities and a well done video can be paused frequently so I can see and understand the nuances of the contraption, etc, et al.

Another case in point is my world which I have not explored very much, it being an ftb world now occupies 18GiB compressed. How many people would want to download that? Granted your world might be considerably smaller, but not withstanding, I think that my point still stands.

It was in no way meant to be an attack on you or credibility, simply only a suggestion to help benefit all of us int he Minecrafting community.
quinn9009 #46
Posted 20 September 2013 - 09:06 AM
I understand, just wanted to offer a world download for proof of my skills, also if anyone is interested I could give a world download and or screen shots for my nuke launcher :P/>, It's fully auto or single fire, and has a range of 370 blocks :D/>
quinn9009 #47
Posted 20 September 2013 - 09:27 AM
Also the program you wrote up is good up until this line:

key = getKey("Your command?") - this line has the problem

if key == "1" then - This line is ok as far as I know :P/>

It runs the program and prints the text, but it says that line is "nil" :(/> can you please help me?
kreezxil #48
Posted 20 September 2013 - 12:34 PM
Where is the link to your download world? or rather is world available online so I can edit the program directly, which goes against everything I'm standing for. :(/>
kreezxil #49
Posted 20 September 2013 - 01:16 PM
Ok, I've made the changes from the comments. So the program is even more leet than it was before. There is no problem with the program as I have written it for you. I've gone and loaded it into one of my computers and test it as you can see from the following YouTube video. Feel free to play, pause, and rewind the video as much as you need to put in the last few lines of code. I have updated the previous pastebin so it has an update in it but it does not have the changes I made in the video, that is for the benefit of you and others. To help you to learn to do it yourself.

http://www.youtube.com/watch?v=Tr4gI2at-R0
quinn9009 #50
Posted 20 September 2013 - 06:55 PM
Thanks man :D/>, I'm going to be offline all weekend :(/>, but I'm going to test the code and play some tekkit :D/>, Monday I'll give my survival world download, and I'll give a download link for my nuke launcher world :D/> :D/> :D/>

But for now good bye :P/>
quinn9009 #51
Posted 23 September 2013 - 01:59 PM
Ok here's the world save downloads: http://www.retributi...90689#p48490689 - This is for the Nuke launcher world :D/>

http://www.mediafire...nd_Survival.zip - this is the link for my Tekkit Classic world with the reactors and the computer :P/>

When you spawn you will be in a large room inside of a large complex, and you will be facing towards a computer ( the program's name is USA ), I didn't have much time for moving the program to the computer so it doesn't work yet, but feel free to explore the world, and if you find a remote in your inventory labeled Teleport 1, go outside of the room and walk to the center of the giant complex you are in, you should then see four flags, above you then should be a a reinforced glass room, fly into it, from there fly up another opening in the ceiling and up to another room in which there is a alcove. Their should be a block of Obsidian, stand on it, or if on the ceiling stand below it, and right click the remote. You will be teleported to a cave system in which I made my first home/base, but that's just my survival world for you enjoy, and thanks for the program kreezxil :D/>

Also to play any of these worlds use Tekkit Classic which you can download the launcher for here: http://www.technicpack.net/download
quinn9009 #52
Posted 24 September 2013 - 01:49 PM
Sorry for being ignorant and not actually trying to learn anything here :(/>

I hope you'll all forgive me, and thanks for the help and advice :)/>

And a special thanks to Kreezil for throwing me a meat bone by correcting my program, and making it useable in a computer :D/> Thank you :)/>
quinn9009 #53
Posted 27 September 2013 - 12:13 PM
Thank you guys sooooo much, the code actually works :D/> :D/> :D/>

I've updated it to include the other functions :D/>, but I haven't fully tested it :(/>
But I will tonight :P/>

And Thanks again guys for all the help, I couldn't of done it without you guys.

P.S. Monday I'll post a link to the paste bin with the working code so everyone and anyone can use it :D/>
quinn9009 #54
Posted 30 September 2013 - 10:40 AM
I've finished the program and customized it further, thanks again for helping guys :)/>

Here's the pastebin URL: http://pastebin.com/GhNkqNcT