Difference between revisions of "Talk:Making a Password Protected Door"

From ComputerCraft Wiki
Jump to: navigation, search
(Doesn't Work)
Line 1: Line 1:
  
== Re: "Make code better, again" ==
+
== While true loop instead of functions ==
  
How is it 'better' to leave the computer running when it's not needed?
+
We need a new picture tutorial, the current one should be using this code:
Assuming this is the desired behaviour, why is it 'better' to reboot the computer each time instead of using a loop?
+
<pre>
And assuming ''that'' is the desired behaviour, why is it 'better' to have the call to os.reboot() repeated inside the if blocks instead of once after the if?<small><span class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:2.102.58.164|2.102.58.164]] ([[User talk:2.102.58.164|talk]] • [[Special:Contributions/2.102.58.164|contribs]]) </span></small><!-- Template:Unsigned -->
+
while true do
 
+
term.clear()
:Loop uses more memory. Also, there's no difference, do you really care that much? <small><span class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:24.20.22.206|24.20.22.206]] ([[User talk:24.20.22.206|talk]] • [[Special:Contributions/24.20.22.206|contribs]]) </span></small><!-- Template:Unsigned -->
+
term.setCursorPos(1,1)
::I reverted changes from two users. This guide is supposed to be a reasonably low level tutorial. Simply slapping code on a page is not a tutorial, hence the previous version with screen shots is more noob friendly. Secondly, the latter version used variables that don't need to be variables. [[Special:Contributions/121.45.75.253|121.45.75.253]] 14:07, 16 April 2012 (UTC)
+
write("Password: ")
 
+
local t = read("*")
== I think this can be more "Noob" friendly ==
+
if t == "password" then
 
+
rs.setOutput("back", true)
i am a noob and have just started to use Computer Craft. I was learning how to make a password protected lock and i understood all of it, until it said, " Now to start it, we have the computer call the function after it declares it." This confused me very much and i was hoping someone could clarify or edit the page to be even more "Noob" friendly. <small><span class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Tpomdreams|Tpomdreams]] ([[User talk:Tpomdreams|talk]] • [[Special:Contributions/Tpomdreams|contribs]]) </span></small><!-- Template:Unsigned -->
+
sleep(2)
 
+
rs.setOutput("back", false)
:Try the 'Better / Alternative Code', you might understand that more. <small><span class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:24.20.22.206|24.20.22.206]] ([[User talk:24.20.22.206|talk]] • [[Special:Contributions/24.20.22.206|contribs]]) </span></small><!-- Template:Unsigned -->
+
else
 
+
end
== Needs work ==
+
end
 
+
</pre>
Should be formatted better and especially with the code and the comments.
+
(a few improvements, plus using a while true loop instead of calling a function over and over again (that crashes the computer after some time)
 
+
== Troubleshooting ==
+
 
+
I used the "Better/Alternative" code and when I start the computer all I get is "bios:206: [string "startup"]:16: '=' expected". Any idea what this means? Any way to fix it?
+
I later tried the normal code and it said "unfinished string"
+
 
+
When write "edit startup" the console responde "access denied"
+

Revision as of 02:51, 3 July 2012

While true loop instead of functions

We need a new picture tutorial, the current one should be using this code:

while true do
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local t = read("*")
if t == "password" then
rs.setOutput("back", true)
sleep(2)
rs.setOutput("back", false)
else
end
end

(a few improvements, plus using a while true loop instead of calling a function over and over again (that crashes the computer after some time)