I had actually figured out there was some sort of syntax error with the "not equals" operator. I simply changed the syntax to read "equals" (obviously altering the program slightly) but it functions now. I am familiar with c and java so this is slightly different .
Do you happen to know how to use the print() function to handle multiple data types (idk how to explain this)
for instance in java i would say | System.out.println("You have: " + t + "attempts."); to execute a print string where t is a calculated value
or in c++ i would say | cout << "You have: " << t << "attempts." << endl;
i would like to do the same thing with this.
Let's say a = 1 and we wanted to print text with that. The symbol used to separate different data types/variables is actually just '..', so all you have to do is:
Hi all, Im new to lua and i just wanted to ask, any way how i can add more correct passwords to this?
answer= read()
if answer == "Password" then
.
.
.
Just wanted to add more then just one correct password, any help?
There are many ways to do this. One way might be to set multiple variables and do this:
pass1 = "apple"
pass2 = "banana"
pass3 = "orange"
answer = read()
if answer == a or answer == b or answer == c then
print("blah")
end
Another way would be with tables, but, considering you're still beginner, try going with that way for now until you feel ready to go into more advanced things like tables.
Hey, I've been playing around with ComputerCraft the last couple days, but in one of my projects I have found the need to be able to put variables in variable names, for a login server. For example, I would like to do something like this:
id, message rednet.receive()
id = tonumber(idn)
if message = "login "..id.." "..(idn.."pass") and (idn.."logged") = false then
(idn.."logged") = true
rednet.send(0, "Logged in. Welcome, "..id)
end
Is there a way to do this? I've googled it but I can't find anything on it.
EDIT: Nevermind, figured out a better way to make my login system.
Hi, I wrote this in Python 2, and I can't figure out how to write the same thing in lua. It's a basic calculator with the four basic functions.
number1 = input("Enter your first number here!: ")
x = input("Enter 1 for +, 2 for -, 3 for *, and 4 for /: ")
number2 = input("Enter your second number here!: ")
Could someone please help me? I'm typing everything that the initial post is telling me to type, but the computer keeps saying "No such program". Could it be because I'm using the Tekkit version?
Hi, I'm just wondering if you can access your programs on disks or computers outside of game if you made them on a tekkit server, I'm trying to write a program and I want to be able to work on it and not have to be on the server, I am the server admin, so I can access the server through FTP if needed.
I am a mac user and i wrote some lua today.
Happy with myself because my lua-coding friend said it would work, i went and tried it on tekkit computer craft.
The result was this:
copy:13:Access Denied.
Please tell me how to run code in computer craft on a mac!!
Could you add onto your tutorial it helped alot but not to the extent that I need :3, BUT I really appreciate this tutorial really helped. It would be cool to teach how to do "startup" programs or how to work with outputs and other types of things.
The Meaning of Life, the Universe, and Everything.
Join Date:
9/21/2011
Posts:
44
Member Details
Can anyone help me?
Im trying to set my rule board up with monitors and I havent a clue how to program with lua.
if anyone could help me translate this
Rules
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods*.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour*, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Don’t hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
Full list of rules with explanations and definitions are viewable at
Thanks for the great article, very helpful, ver well-written. Unfortunately, I just can't understand even the simplest coding. It's not your fault, it's just me. I'm not stupid, or anything, it's just computers confuse me. *sigh*...
im making my first program ever, and ive ran into a problem, i keep getting a "attempt to call nill" with this code
if redstone.chekcOutput("back", true) then
input = read()
input = "back to left"
input = "back to right"
input = "back to bottom"
input = "bottom to top"
input = "shutdown"
if input == ("back to left") then
print("Diverting from BACK to LEFT...")
sleep(3)
redstone.setOutput("left", true)
print("Done!")
else
if input == "back to top" then
print("Diverting from BACK to TOP...")
sleep(3)
redstone.setOutput("top", true)
print("Done!")
end
if input == "back to bottom"
then
print("Diverting from BACK to BOTTOM...")
sleep(3)
redstone.setOutput("bottom", true)
print("Done!")
end
if input == "back to right"
then
print("Diverting from BACK to RIGHT...")
sleep(3)
redstone.setOutput("right", true)
print("Done!")
end
if input == "shutdown"
then
os.shutdown()
end
end
else os.shutdown()
end
any help is great. i should mention this is my first programming language im learning, so cut me some slack if i did something retarded. thanks!
Ok, im a crazy mod person. Now that we have established that, i have a question.
is there any way to connect the computer to bundled cable and have it output say only to green wires connected to that bundled cable (im talking redpower cable and alloy wires) and if so, what are the commands? also can u make it respond to a green wire signal from a bundled cable? if so, what are the commands? another question - is it possible to set variables with 1 program, but have a completely seperate program (on the same computer) access that variable? if so, how?
-- this will really help me out dude
also A+ on ur tutorial
Edit: sorry about the "dude" if ur a girl then change that to "dudett"
Rollback Post to RevisionRollBack
I came up with the idea for Mo' Armor, a mod being developed by CORE modders.
When I type cd rom/programs/custom ,it tells me "Not a directory". I've put the folder and the file exactly where you instructed us to put it and it gives me that message. Do you know what the problem is?
help?
THANKYOU SO MUCH KEEP IT COMING
Working on that now! I will be posting them on computercraft.info, though, but I will make threads on here to link to them! Either that or copy/paste.
It probably does make them, just hides the .lua extension. I don't run Mac so I can't really say else, try asking on the IRC channel here: http://webchat.esper.net/?channels=#computercraft.
Let's say a = 1 and we wanted to print text with that. The symbol used to separate different data types/variables is actually just '..', so all you have to do is:
The same goes for write().
There are many ways to do this. One way might be to set multiple variables and do this:
Another way would be with tables, but, considering you're still beginner, try going with that way for now until you feel ready to go into more advanced things like tables.
Happy scripting!
id, message rednet.receive()
id = tonumber(idn)
if message = "login "..id.." "..(idn.."pass") and (idn.."logged") = false then
(idn.."logged") = true
rednet.send(0, "Logged in. Welcome, "..id)
end
Is there a way to do this? I've googled it but I can't find anything on it.
EDIT: Nevermind, figured out a better way to make my login system.
number1 = input("Enter your first number here!: ")
x = input("Enter 1 for +, 2 for -, 3 for *, and 4 for /: ")
number2 = input("Enter your second number here!: ")
if x == 1:
sum = number1 + number2
print sum
elif x == 2:
sumx = number1 - number2
print sumx
elif x == 3:
product = number1 * number2
print product
elif x == 4:
quotient = number1 / number2
print quotient
else:
print ("You have not entered a valid function!")
raw_input("Press enter to exit")
Thanks in advance!
-Matrixmage
Happy with myself because my lua-coding friend said it would work, i went and tried it on tekkit computer craft.
The result was this:
copy:13:Access Denied.
Please tell me how to run code in computer craft on a mac!!
Im trying to set my rule board up with monitors and I havent a clue how to program with lua.
if anyone could help me translate this
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods*.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour*, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Don’t hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
If it helps my screen is 5x4high
This tutorial was (to say the least) very very helpful.
what's the end for? there is nothing to end
also is that the whole code?
if redstone.chekcOutput("back", true) then
input = read()
input = "back to left"
input = "back to right"
input = "back to bottom"
input = "bottom to top"
input = "shutdown"
if input == ("back to left") then
print("Diverting from BACK to LEFT...")
sleep(3)
redstone.setOutput("left", true)
print("Done!")
else
if input == "back to top" then
print("Diverting from BACK to TOP...")
sleep(3)
redstone.setOutput("top", true)
print("Done!")
end
if input == "back to bottom"
then
print("Diverting from BACK to BOTTOM...")
sleep(3)
redstone.setOutput("bottom", true)
print("Done!")
end
if input == "back to right"
then
print("Diverting from BACK to RIGHT...")
sleep(3)
redstone.setOutput("right", true)
print("Done!")
end
if input == "shutdown"
then
os.shutdown()
end
end
else os.shutdown()
end
any help is great. i should mention this is my first programming language im learning, so cut me some slack if i did something retarded. thanks!
but now the computer shuts down when you run the program, i know it has to do with the os.shutdown()
how do i fix this?
please and thank you!
what have i done wrong i followed all the instruction exactly , help me
is there any way to connect the computer to bundled cable and have it output say only to green wires connected to that bundled cable (im talking redpower cable and alloy wires) and if so, what are the commands? also can u make it respond to a green wire signal from a bundled cable? if so, what are the commands? another question - is it possible to set variables with 1 program, but have a completely seperate program (on the same computer) access that variable? if so, how?
-- this will really help me out dude
also A+ on ur tutorial
Edit: sorry about the "dude" if ur a girl then change that to "dudett"