I am a newb programmer, and I have created my first program that I wrote in free time at school. I want someone to please test it, and if it doesn't work to tell me what needs fixed. It is a redstone program that has you select the side to send the pulse.
Heres the code
__________________________________________________________________________________________________________
off = off
bottom = bottom
back = back
front = front
right = right
left = left
print ("Which side will the redstone pulse be sent?")
if "top" then
redstone.setOutput ("top", true)
if "bottom" then
redstone.setOutput ("bottom", true)
if "back" then
redstone.setOutput ("back", true)
if "front" then
redstone.setOutput ("front", true)
if "right" then
redstone.setOutput ("right", true)
if "left" then
redstone.setOutput ("left", true)
if "off" then
redstone.setOutput ("top", false)
redstone.setOutput ("bottom", false)
redstone.setOutput ("back", false)
redstone.setOutput ("front", false)
redstone.setOutput ("right", false)
redstone.setOutput ("left", false)
os.reboot()
print ("Proccessing.........")
end
________________________________________________________________________________________________________
Constructive critisim would be welcome, remember this is my first script I didn't just copy! All is used from my mind.
If you're wondering how I learned it, I had to copy a password door script a couple times yesterday. That was kinda like studying lua for me.
os.shutdown()
print ("If you help, thank you!")
end
3 replies to this topic
#1
Posted 26 March 2012 - 07:00 PM
#2
Posted 26 March 2012 - 07:18 PM
No it does not work. You should definitely take some beginner lua tutorials as your basic syntax is quite off.
Take my interactive tutorial in the tutorials section when you get a chance.
Take my interactive tutorial in the tutorials section when you get a chance.
#3
Posted 26 March 2012 - 07:36 PM
Kadecamz, on 26 March 2012 - 07:00 PM, said:
I am a newb programmer, and I have created my first program that I wrote in free time at school. I want someone to please test it, and if it doesn't work to tell me what needs fixed. It is a redstone program that has you select the side to send the pulse.
Heres the code
__________________________________________________________________________________________________________
print ("Which side will the redstone pulse be sent?")
Input = read()
if Input == "top" then
redstone.setOutput ("top", true)
if Input =="bottom" then
redstone.setOutput ("bottom", true)
if Input =="back" then
redstone.setOutput ("back", true)
if Input =="front" then
redstone.setOutput ("front", true)
if Input =="right" then
redstone.setOutput ("right", true)
if Input =="left" then
redstone.setOutput ("left", true)
if Input =="off" then
redstone.setOutput ("top", false)
redstone.setOutput ("bottom", false)
redstone.setOutput ("back", false)
redstone.setOutput ("front", false)
redstone.setOutput ("right", false)
redstone.setOutput ("left", false)
os.reboot()
print ("Proccessing.........")
end
________________________________________________________________________________________________________
Constructive critisim would be welcome, remember this is my first script I didn't just copy! All is used from my mind.
If you're wondering how I learned it, I had to copy a password door script a couple times yesterday. That was kinda like studying lua for me.
os.shutdown()
print ("If you help, thank you!")
end
Heres the code
__________________________________________________________________________________________________________
print ("Which side will the redstone pulse be sent?")
Input = read()
if Input == "top" then
redstone.setOutput ("top", true)
if Input =="bottom" then
redstone.setOutput ("bottom", true)
if Input =="back" then
redstone.setOutput ("back", true)
if Input =="front" then
redstone.setOutput ("front", true)
if Input =="right" then
redstone.setOutput ("right", true)
if Input =="left" then
redstone.setOutput ("left", true)
if Input =="off" then
redstone.setOutput ("top", false)
redstone.setOutput ("bottom", false)
redstone.setOutput ("back", false)
redstone.setOutput ("front", false)
redstone.setOutput ("right", false)
redstone.setOutput ("left", false)
os.reboot()
print ("Proccessing.........")
end
________________________________________________________________________________________________________
Constructive critisim would be welcome, remember this is my first script I didn't just copy! All is used from my mind.
If you're wondering how I learned it, I had to copy a password door script a couple times yesterday. That was kinda like studying lua for me.
os.shutdown()
print ("If you help, thank you!")
end
It does not work but here's some tips:
To find what a user typed, write "anything" = read()
To make something happen if they type a command, do this:
(This time I'm gonna use input = read()
If input == "Hello" then
Print("Hi")
End
So I'd they type hello, it will print hi
I fixed the code for you*
#4
Posted 26 March 2012 - 10:49 PM
Should be fixed:
s=rs.getSides()
while true do
print("Choose side:")
in = read()
if in =="top" or in =="left" or in =="right" or in =="back" or in =="front" or in =="bottom" then
rs.setOutput(in,true)
elseif in =="off" then
for i=1,#s do
rs.setOutput(s[i],false)
end
end
end
Phew, lua + smartphone ="Hard!"
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











