Sorry for the noob question but how can I link programs?
I want try and make it so I can choose an option in one program and have it automatically start another.
Sorry for the noob question but how can I link programs?
I want try and make it so I can choose an option in one program and have it automatically start another.
Thanks!
nice tutorial btw :biggrin.gif:
Indeed you can! The API for that is in the shell and it's 'shell.run( program, arguments )'. Also run 'help shellapis' to see other API's in the shell.
Excuse me everyone on being late to updating the tutorial, this past week I've been sick with a pretty bad cold and schoolwork had me tied up a bit, as well as helping Dan test some early builds. I promise to have the next part out today!
Can i set a custom variable like set var ("redstone.setOutput("back", false)") and how do i set the command to be different
if redstone.getInput("right",true) then --Checks if this is true (example of a comment note)
redstone.setOutput("back",true)
print("Turning power on!")
else
redstone.setOutput("back",false)
print("Turning power off!")
end
I want to enter Power then it runs that commad
The best way to do that is through functions which is also something I did not cover yet but will in the tutorial coming out after the next. Functions are one of the greatest things to happen to programming and scripting. Functions allow you to list a bunch of commands and such in order, possibly even loops, but pretty much anything you want, and have it all be called by what you titled it as. For example:
function printHello()
print("Hello, world!")
end
To run that function would be:
printHello()
You can put ANYTHING between the line that starts with 'function' and the last 'end' and everytime you run 'printHello()' it will run all of it. Now for your case, this is something that I've used quite a lot recently, not quite in the same way but similar. To do that, you put this above the first time you'll call the function and you define it and enter what it does:
function checkPower()
if redstone.getInput("right",true) then --Checks if this is true (example of a comment note)
redstone.setOutput("back",true)
print("Turning power on!")
else
redstone.setOutput("back",false)
print("Turning power off!")
end
end
And finally, to run that would be simply 'checkPower()'.
Hope this helps! Also, Sorry for taking so long for the next tutorial, I just recently had some computer issues (I run Linux so it's not a virus :tongue.gif:) and some stuff suddenly came up. Will be out tomorrow latest, or, if not tomorrow, tonight!
Can I get some help? I can't get my program to call another program. I am trying to build a personal OS for a power station. My friend built the light program but I can't get my os to call it. Should it be shell.run ("light") or something else?
Edit: Nevermind, I found the bug. >.< I forgot to put the quotes around my input value.
I have problem. I'm making adventure map with Computercraft and PowerCraft (may use also SecretRooms mod but not sure) and thought about using LuaJava to output some text to Minecraft's chat area. But don't know how. Can you help me?
I do not know anything about LuaJava other than it can be enabled in CC's config file in /.minecraft/config/. Why not just print text with Lua?
Thanks soo much! I realize some of this code from a program which name I can not recall. If anything. Just give me a list of the commands and tell me what they do and you'll find me being able to make almost anything :biggrin.gif:
Thanks soo much! I realize some of this code from a program which name I can not recall. If anything. Just give me a list of the commands and tell me what they do and you'll find me being able to make almost anything :biggrin.gif:
Hehe thanks, just check the help files in /computercraft/lua/rom/help and that lists quite a lot. They're all also visible by entering help in your computer.
Please give me ideas for tutorials! I'd love to do more!
The best part of the tutorial is... I understand what your saying! I've seen a few tutorials that I couldn't understand what they were babbling about...
Great Tutorial, will be very useful for new programmers! :smile.gif:
Could you please post a command list of minecraft-type commands in computercraft?
(Minecraft-Type meaning the ones that aren't normally in Lua)
Also, DarkHog:
Thanks! I get inspiration from Bucky Roberts (TheNewBoston on youtube; check him out, he has the best tutorials for everything, especially certain programming languages).
All those commands are easily found in the help files or the CC-Wiki, although that is a good idea to make a list of every unique command that Dan made that isn't with the standard Lua libs. I'll look into it!
You can find all the API's with 'help apis' and then 'help <name of api>'.
http://www.squidoo.com/minecraft-mod-tutorial
Exactly the same as the tutorial here, but the formatting for the sections that are in code here is messed up. It pretty much looks like someone copy/pasted the OP.
Sorry for the noob question but how can I link programs?
I want try and make it so I can choose an option in one program and have it automatically start another.
Thanks!
nice tutorial btw :biggrin.gif:
Indeed you can! The API for that is in the shell and it's 'shell.run( program, arguments )'. Also run 'help shellapis' to see other API's in the shell.
Excuse me everyone on being late to updating the tutorial, this past week I've been sick with a pretty bad cold and schoolwork had me tied up a bit, as well as helping Dan test some early builds. I promise to have the next part out today!
The best way to do that is through functions which is also something I did not cover yet but will in the tutorial coming out after the next. Functions are one of the greatest things to happen to programming and scripting. Functions allow you to list a bunch of commands and such in order, possibly even loops, but pretty much anything you want, and have it all be called by what you titled it as. For example:
To run that function would be:
You can put ANYTHING between the line that starts with 'function' and the last 'end' and everytime you run 'printHello()' it will run all of it. Now for your case, this is something that I've used quite a lot recently, not quite in the same way but similar. To do that, you put this above the first time you'll call the function and you define it and enter what it does:
And finally, to run that would be simply 'checkPower()'.
Hope this helps! Also, Sorry for taking so long for the next tutorial, I just recently had some computer issues (I run Linux so it's not a virus :tongue.gif:) and some stuff suddenly came up. Will be out tomorrow latest, or, if not tomorrow, tonight!
Edit: Nevermind, I found the bug. >.< I forgot to put the quotes around my input value.
Visit MadPC on madpc.forumotion.com
I do not know anything about LuaJava other than it can be enabled in CC's config file in /.minecraft/config/. Why not just print text with Lua?
Check it out!
Sorry, all I can do is link to a couple programs that tried using it. It's possible, except it's extremely slow and inefficient.
Editing or making a new OS is kind of a big thing, but a good example of one is RedWorks. I'll link it when the latest version is released.
Hehe thanks, just check the help files in /computercraft/lua/rom/help and that lists quite a lot. They're all also visible by entering help in your computer.
Please give me ideas for tutorials! I'd love to do more!
Trying to make my computer have a password, but it won't work!
Code:
correctpassword = Farming
print ("Starting systematics...")
sleep (2)
print ("Loading programs...")
sleep (4)
print ("Loaded. Please enter password.")
password = read ()
if password == (correctpassword) then
print ("Password accepted. Welcome to the")
print ("desktop.")
print ("if you need help, type "help"")
print ("if you would like to harvest your")
print ("sugarcane, type "harvest"")
else
print ("Password denied.")
os.shutdown()
end
I typed it exactly like that, but whenever I start up, it says:
[string "startup"]:20: ')' expected
Please help!!!
How to send a button pulse anytime? Try 'help redpulse'
You didn't make your password a string, set the first line to:
correctpassword = "Farming"
My first reply here: Not what I meant. I meant how do you make it so I type in a command and it pulses.
My second reply here: Okay, did that, but now it only says [string "startup"]:11: 'then' expected.
Look at the line 'if password == (correctpassword) then'. Remove those parentheses.
Thanks! I get inspiration from Bucky Roberts (TheNewBoston on youtube; check him out, he has the best tutorials for everything, especially certain programming languages).
All those commands are easily found in the help files or the CC-Wiki, although that is a good idea to make a list of every unique command that Dan made that isn't with the standard Lua libs. I'll look into it!
You can find all the API's with 'help apis' and then 'help <name of api>'.
What exactly do you mean? If you make a file with edit you save it, go to its directory and run it by entering its filename.
Exactly the same as the tutorial here, but the formatting for the sections that are in code here is messed up. It pretty much looks like someone copy/pasted the OP.
Where you aware of this?