-- Gui by plazter
-- reactor + light control system by rednet
shell.run("clear")
print "##############################################"
print "# Control system #"
print "# Terminal # ### #"
print "##############################################"
print "# 1.Turn on reactor #"
print "# 2.Turn off reactor #"
print "# 3.Turn on light #"
print "# 4.Turn off light #"
print "# 5.exit #"
write("# Choice: #")
input = read()
if 1 = rednet.send(ID1, true)
if 2 = rednet.send(ID1, false)
if 3 =rednet.send(ID2, true)
if 4 =rednet.send(ID2, false)
if 5 =os.reboot()
print "# #"
print "# #"
print "# #"
print "##############################################"
print "###############by plazter#######################"
print "##############################################"
end
end
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Lua Gui] Something is wrong !
Started by plazter, 14 March 2012 - 05:17 PMPosted 14 March 2012 - 06:17 PM
im currently makeing this UI as my first real project, working on another 1 just looking better (the code below is messed up, but what i need its really what i want is to get it to function with typeing in an answer, could anyone help ? :mellow:/>/>
Posted 14 March 2012 - 06:21 PM
input=tonumber(read())
Posted 14 March 2012 - 06:29 PM
There is some mistake in line no. 17(if 2=) aswell cant find it :s
Posted 14 March 2012 - 06:49 PM
if 1 == input then rednet.send(ID1, true)
That is the correct syntax for an 'if'
That is the correct syntax for an 'if'
Posted 14 March 2012 - 06:53 PM
-- Gui by plazter
-- reactor + light control system by rednet
shell.run("clear")
print "##############################################"
print "# Control system #"
print "# Terminal # ### #"
print "##############################################"
print "# 1.Turn on reactor #"
print "# 2.Turn off reactor #"
print "# 3.Turn on light #"
print "# 4.Turn off light #"
print "# 5.exit #"
write("# Choice: #")
input=tonumber(read())
if 1 == input then rednet.send(ID1,right,true)
if 2 == input then rednet.send(ID1,right,false)
if 3 == input then rednet.send(ID2,left,true)
if 4 == input then rednet.send(ID2,left,false)
if 5 =os.reboot()
print "# #"
print "# #"
print "# #"
print "##############################################"
print "###############by plazter#####################"
print "##############################################"
end
end
So this would acutally work?
Posted 14 March 2012 - 07:00 PM
tbh, this is god damn hard to get oO god i need to start reading alot more :mellow:/>/>
- now that i have edite those "if # == input then" it says:("Bios:206:[string"4"]:31: 'end' expected (to close 'if' at line 18)
.. any easy way i can find those faults? and a easy way to edit em?
- now that i have edite those "if # == input then" it says:("Bios:206:[string"4"]:31: 'end' expected (to close 'if' at line 18)
.. any easy way i can find those faults? and a easy way to edit em?
Posted 14 March 2012 - 07:08 PM
if 1 == input then rednet.send(ID1, true) end
forgot about the end, sorry
forgot about the end, sorry
Posted 14 March 2012 - 07:10 PM
Dont say sorry i think u helped me enough to be able to do mistakes :mellow:/>/>
Posted 14 March 2012 - 07:19 PM
-- Gui by plazter
-- reactor + light control system by rednet
shell.run("clear")
print "##############################################"
print "# Control system #"
print "# Terminal # ### #"
print "##############################################"
print "# 1.Turn on reactor #"
print "# 2.Turn off reactor #"
print "# 3.Turn on light #"
print "# 4.Turn off light #"
print "# 5.exit #"
write("# Choice: #")
input=tonumber(read())
print "# #"
print "# #"
print "# #"
print "##############################################"
print "###############by plazter#####################"
print "##############################################"
if 1 == input then rednet.send(ID1,true) end
if 2 == input then rednet.send(ID1,false) end
if 3 == input then rednet.send(ID2,true) end
if 4 == input then rednet.send(ID2,false) end
if 5 == input thenos.reboot() end
So liraal, this code would be a completed design or how do i manage it to get the buttom part along? oO
Posted 14 March 2012 - 08:54 PM
the convention is:
in your case is:
i know the order doesn't matter, but you know..it's the convention
if <variable name> == <comparison value> then <do some stuff> end
in your case is:
if input == 1 then rednet.send(ID1, true) end
which means "if the content of the variable 'input' is equal to 1 then …"i know the order doesn't matter, but you know..it's the convention
Posted 14 March 2012 - 11:52 PM
My final edition that actually works:D
!!OBS!!
YOU WILL HAVE TO PUSH THE "#" Your self! :)/>/> aint hard:D!
Tell me what you think of it :)/>/>
- im a noobish coder :D/>/>
-- Gui by plazter
-- reactor + light control system by rednet
shell.run("clear")
print "##############################################"
print "# Plazter GUI v.1 #"
print "# Terminal # ### #"
print "##############################################"
print "# 1.Turn on reactor #"
print "# 2.Turn off reactor #"
print "# 3.Turn on light #"
print "# 4.Turn off light #"
print "# 5.exit #"
--write("# Choice: ")print " #"
--input=tonumber(read()) print" #"
print "# " "
print "# #"
print "# #"
print "# #"
print "# #"
print "##############################################"
print "###############by plazter#####################"
print "##############################################"
term.setCursorPos(20.10)
write("n# choice: ")
input=tonumber(read())
shell.run("clear")
if 1 == input then rs.setOutput("left",true) end
if 2 == input then rs.setOutput("left",false) end
if 3 == input then rs.setOutput("top",true) end
if 4 == input then rs.setOutput("top",false) end
if 5 == input thenos.reboot() end
-- Thanks to liraal and mowno for the helping hands
-- this GUI is Noob secure, if i can YOU CAN!
!!OBS!!
YOU WILL HAVE TO PUSH THE "#" Your self! :)/>/> aint hard:D!
Tell me what you think of it :)/>/>
- im a noobish coder :D/>/>
Edited on 14 March 2012 - 10:54 PM
Posted 15 March 2012 - 07:58 AM
-- Gui by plazter
-- reactor + light control system by rednet
local exit = 0
while exit == 0 do
shell.run("clear")
print "##############################################"
print "# Plazter GUI v.1 #"
print "# Terminal # ### #"
print "##############################################"
print "# 1.Turn on reactor #"
print "# 2.Turn off reactor #"
print "# 3.Turn on light #"
print "# 4.Turn off light #"
print "# 5.exit #"
--write("# Choice: ")print " #"
--input=tonumber(read()) print" #"
print "# " "
print "# #"
print "# #"
print "# #"
print "# #"
print "##############################################"
print "###############by plazter#####################"
print "##############################################"
term.setCursorPos(20.10)
write("\n# choice: ")
input=tonumber(read())
shell.run("clear")
if 1 == input then
rs.setOutput("left",true)
elseif 2 == input then
rs.setOutput("left",false)
elseif 3 == input then
rs.setOutput("top",true)
elseif 4 == input then
rs.setOutput("top",false)
elseif 5 == input then
exit = 1
else
exit = 0
end
end
os.reboot()
-- Thanks to liraal and mowno for the helping hands
-- this GUI is Noob secure, if i can YOU CAN!
Well your code looks good, i would just add a few basic logic steps to it, for example using "elseif" other wise you are running 5 if checks instead of just one from the elseif. Also, What do you expect of you computer when you say hit 1 and turn on/off the reactor? From your code you would of had to re-run the program assuming its not the startup of the computer. I added a while-do loop that will continue to apply options to the user until exit is hit, then it will break the loop and reboot the computer. Other than that it looks good! Nice job.
Posted 15 March 2012 - 04:28 PM
so the code u gave me there is just a little modify that makes it go loop? :D/>/>
Posted 15 March 2012 - 05:49 PM
in short, yes. But its mainly the elseif that i would stress if you continue to do more coding.
Posted 16 March 2012 - 07:13 AM
in short, yes. But its mainly the elseif that i would stress if you continue to do more coding.
a wuut?