This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jag's profile picture

Help with coding errors

Started by jag, 26 September 2012 - 03:55 AM
jag #1
Posted 26 September 2012 - 05:55 AM
So I was playing on a server, and I made a computer and tried to make a login program.
This is the code:
Spoiler
function checkLogin(uname, pass)
  -- Yes, very easy to hack...
  if uname ~= "admin" and pass ~= "password" then
		return true
  else
		return false
  end
end

function login()
  local inputUname = ""
  local inputPass = ""

  while not checkLogin(inputUname, inputPass) do
		term.clear()
		if inputUname == "" or inputPass == "" then
		  term.setCursorPos(3,2)
		  print("Wrong username or password!")
		end
		term.setCursorPos(3,3)
		print("Username: ") -- 10 char long
		term.setCursorPos(3,4)
		print("Password: ") -- 10 char long

		-- Now comes the input
		term.setCursorPos(13,3)
		inputUname = read()
		term.setCursorPos(13,4)
		inputPass = read("*")
  end
  term.clear()
  term.setCursorPos(3,2)
  print("Correct login!")
  sleep(2)
end

login()
But I'm keep on getting the error:
bios:206: [string "index"]:34: 'end' expected (to close 'function' at line 9)
(Now is a good time as any to say that the programs name is index)


(BTW I'm planning to make a OS, so that's why the folder is named OS)

EDIT: I tried the code on single player and it worked. So the server must have gotten the problem.
Spoiler

stilldabomb #2
Posted 26 September 2012 - 06:27 AM
Works fine for me, you being a troll? XD
Luanub #3
Posted 26 September 2012 - 06:40 AM
The code looks good.

Also this should be in ask-a-pro, the programs section is for finished programs.
stilldabomb #4
Posted 26 September 2012 - 07:08 AM
The code looks good.

Also this should be in ask-a-pro, the programs section is for finished programs.

Like luanub said!
Doyle3694 #5
Posted 26 September 2012 - 07:49 AM
Else, do this:
cal password = "CreepersSuck"
local passwordBypass = "CreepersAreGreat"
local passwordenter = ""

os.pullEvent = os.pullEventRaw

function open()
  rs.setOutput("right", true)
sleep(2)
  rs.setOutput("right", false)
end

function ClearAndPrint()
   term.clear()
   term.setCursorPos(1,1)
   print("Please Enter The Correct Password:")
end

while true do
  ClearAndPrint()
  passwordenter = read("*")
  if passwordenter == password then
	  open()
  else
	 if passwordenter == password then
		break
	 else
	 print("Wrong Password")
	 sleep(2)
	 end
  end
end



My own password program, un hackable :D/>/>
If you like coding then read through this and learn and then formulate your own program of what you learned, I don't think it's that much but yeah :P/>/>
Luanub #6
Posted 26 September 2012 - 07:53 AM
, un hackable :P/>/>

Very hackable, there's not even ctrl+t prevention.
jag #7
Posted 26 September 2012 - 08:37 AM
The code looks good.

Also this should be in ask-a-pro, the programs section is for finished programs.
Ok, thanks for the help
Doyle3694 #8
Posted 26 September 2012 - 08:56 AM
oh lol, posted wrong version *updates*
jag #9
Posted 26 September 2012 - 04:31 PM
oh lol, posted wrong version *updates*
I'm not following you…
what do you mean with "version *updates*"?

, un hackable :P/>/>

Very hackable, there's not even ctrl+t prevention.
BTW, how do you make a CTRL+T protection?
Cranium #10
Posted 26 September 2012 - 04:48 PM
BTW, how do you make a CTRL+T protection?
If you don't know how to do that, then you need to search the forums a little farther.
Doyle3694 #11
Posted 26 September 2012 - 05:55 PM
I ment that I updated my post, used the wrong version of my program.
jag #12
Posted 26 September 2012 - 06:51 PM
BTW, how do you make a CTRL+T protection?
If you don't know how to do that, then you need to search the forums a little farther.
The word I'm thinking on dosen't exists in the english language, so I'm going to say it in our language:
Det där var en väldigt dryg kommentar, skulle du någonsin kunna tänka dig vara snäll någon gång?
Ah, there I said it.

Now, I didn't research because it's easier to ask. Like, you'll for example ask your friend what the main characters name of a certain movie is instead of going to the largest library in town to find out.
Cranium #13
Posted 26 September 2012 - 07:03 PM
I think I got the gist of what you were trying to say, using Google Translate.
That was a little goes a long comment, would you ever ever consider being nice at some point?
I am usually nice. I just don't like it when someone posts a question that is answered on so many posts. I did not mean to offend you, I just wanted to suggest that you search the forums a little harder, since it would be very easy to find.
GopherAtl #14
Posted 26 September 2012 - 07:08 PM
And your friend doesn't mind, because he's, y'know, your friend, and you were probably hanging out anyway. We're a crowd of complete strangers who've already taken the time to answer these simple questions eleventy billion times before for other complete strangers for no reason except that we're nice like that. Flatly refusing to search for existing answers in favor of making someone explain it for the eleventy-billion-and-first time is lazy and selfish, and taking advantage of our niceness.

</rant>
jag #15
Posted 26 September 2012 - 07:14 PM
I think I got the gist of what you were trying to say, using Google Translate.
That was a little goes a long comment, would you ever ever consider being nice at some point?
I am usually nice. I just don't like it when someone posts a question that is answered on so many posts. I did not mean to offend you, I just wanted to suggest that you search the forums a little harder, since it would be very easy to find.

Ok, cool.

Btw google translate isn't the best :P/>/>
the word dryg in swedish is like "the person gives an impression of that he/she is better and more important then the others, in a in-mature way" - Wiktionary :D/>/>
So if you for example send a super in-mature text message to someone then you're "dryg".
jag #16
Posted 26 September 2012 - 07:27 PM
And your friend doesn't mind, because he's, y'know, your friend, and you were probably hanging out anyway. We're a crowd of complete strangers who've already taken the time to answer these simple questions eleventy billion times before for other complete strangers for no reason except that we're nice like that. Flatly refusing to search for existing answers in favor of making someone explain it for the eleventy ¡! There's nothing called "eleventy" !¡ -billion-and-first time is lazy and selfish, and taking advantage of our niceness.

</rant>
There's a big different between strangers in the street and strangers on the internet.
I can't imagine that Cranium have answered 11 000 000 000 000 questions related to my question.
And I'm going to be offended from you when you say that I'm "lazy" and "selfish" if you think that's what everyone are that asks a question on the internet (that isn't obvious).
GopherAtl #17
Posted 26 September 2012 - 07:46 PM
It's not asking questions taht was the problem. This place is for asking questions (Well, technically the forum a couple down from this labeled "ask a pro" is for asking questions, but that's beside the point). What I took offense to was the assertion that you didn't search because it's "easier to ask." Easier for who? Only you. For everyone else it's easier if you searched. So, you're trading our convenience for your convenience. Who's being dryg here exactly?
</done>
Cranium #18
Posted 26 September 2012 - 07:49 PM
The comparable term in english would probably be douchebag. It's always hard to translate colloquialisms between languages.
jag #19
Posted 26 September 2012 - 08:39 PM
The comparable term in english would probably be douchebag. It's always hard to translate colloquialisms between languages.
Agreed!
jag #20
Posted 26 September 2012 - 08:42 PM
It's not asking questions taht was the problem. This place is for asking questions (Well, technically the forum a couple down from this labeled "ask a pro" is for asking questions, but that's beside the point). What I took offense to was the assertion that you didn't search because it's "easier to ask." Easier for who? Only you. For everyone else it's easier if you searched. So, you're trading our convenience for your convenience. Who's being dryg here exactly?
</done>
You are really missing the point! If they already know the answer (and I thought that he did) then it would be easier for me and like no different for him.

And what's up with the tag at the end of your posts?
RemoteMine #21
Posted 27 September 2012 - 02:52 AM
I actually have a solution here :P/>/> ok so go download the version of CC you are using, unzip it and go to the folder called lua inside it, there should be a document called bios.lua, open it with Notepad (if you have windows) or TextEdit (if you have mac) and go to line 206. The rest is kinda self-explantory. Reply to this if you don't know what to do after this.

P.S After you have edited it right, copy it and paste it to pastebin, get the pastebin code, go to your password computer, and then do pastebin get.
Try using it after that, if you edited it right, it should work, otherwise, just write/get another one.

Hope this works! - RemoteMine
jag #22
Posted 27 September 2012 - 06:59 AM
I actually have a solution here :P/>/> ok so go download the version of CC you are using, unzip it and go to the folder called lua inside it, there should be a document called bios.lua, open it with Notepad (if you have windows) or TextEdit (if you have mac) and go to line 206. The rest is kinda self-explantory. Reply to this if you don't know what to do after this.

P.S After you have edited it right, copy it and paste it to pastebin, get the pastebin code, go to your password computer, and then do pastebin get.
Try using it after that, if you edited it right, it should work, otherwise, just write/get another one.

Hope this works! - RemoteMine
The main problem is, it's not my server, and it's using tekkit. So it dosen't got the newest update with the pastebin program…
stilldabomb #23
Posted 27 September 2012 - 07:13 AM

os.pullEvent = os.pullEventRaw
Would make it so you can not use CTRL + T and

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
if canExit then
os.pullEvent = oldPullEvent
end
would thus make it so they can exit if a variable is true! :P/>/>
robhol #24
Posted 27 September 2012 - 07:24 AM
And your friend doesn't mind, because he's, y'know, your friend, and you were probably hanging out anyway. We're a crowd of complete strangers who've already taken the time to answer these simple questions eleventy billion times before for other complete strangers for no reason except that we're nice like that. Flatly refusing to search for existing answers in favor of making someone explain it for the eleventy ¡! There's nothing called "eleventy" !¡ -billion-and-first time is lazy and selfish, and taking advantage of our niceness.

</rant>
There's a big different between strangers in the street and strangers on the internet.
I can't imagine that Cranium have answered 11 000 000 000 000 questions related to my question.
And I'm going to be offended from you when you say that I'm "lazy" and "selfish" if you think that's what everyone are that asks a question on the internet (that isn't obvious).

Then look for completely basic info before you post. It's on one of the first wiki pages you'll look at,
RemoteMine #25
Posted 28 September 2012 - 05:30 AM
I actually have a solution here :P/>/> ok so go download the version of CC you are using, unzip it and go to the folder called lua inside it, there should be a document called bios.lua, open it with Notepad (if you have windows) or TextEdit (if you have mac) and go to line 206. The rest is kinda self-explantory. Reply to this if you don't know what to do after this.

P.S After you have edited it right, copy it and paste it to pastebin, get the pastebin code, go to your password computer, and then do pastebin get.
Try using it after that, if you edited it right, it should work, otherwise, just write/get another one.

Hope this works! - RemoteMine
The main problem is, it's not my server, and it's using tekkit. So it dosen't got the newest update with the pastebin program…
What version of CC, they might have the http API disabled, ask them to enable it.. Or if you can't do that and you are REALLY, REALLY desparate, copy it out.. :D/>/>