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

Text to Binary converter (API)

Started by KidBrine, 19 April 2017 - 08:18 PM
KidBrine #1
Posted 19 April 2017 - 10:18 PM
This API lets you convert from text to binary and back
ex: Brinary.TextBin("f") returns 01100110
ex: Brinary.BinText(01100110) returns "f"
pastebin link: https://pastebin.com/THUYFuSG
Edited on 19 April 2017 - 08:29 PM
Exerro #2
Posted 19 April 2017 - 11:42 PM
Uhm. This isn't valid Lua.



function TextBin(text.byte(ch))
  r = ""
  chn(128) chn(64) chn(32) chn(16)
  chn(8) chn(4) chn(2) chn(1)
  return cc
end

Not even the algorithm you failed to implement works. If you put in 128, it'd be greater than all of 1, 2, 4, 8…, so you'd get 11111111 back.

Edit: …in theory. I mean you wouldn't because the code isn't even valid syntactically.
Edited on 19 April 2017 - 09:46 PM
KidBrine #3
Posted 20 April 2017 - 01:56 AM
Uhm. This isn't valid Lua.



function TextBin(text.byte(ch))
  r = ""
  chn(128) chn(64) chn(32) chn(16)
  chn(8) chn(4) chn(2) chn(1)
  return cc
end

Not even the algorithm you failed to implement works. If you put in 128, it'd be greater than all of 1, 2, 4, 8…, so you'd get 11111111 back.

Edit: …in theory. I mean you wouldn't because the code isn't even valid syntactically.
I fixed my code and tested it, it should be goochie now.
before pointing out an error in the code test it first and tell me how to activate the bug.
KingofGamesYami #4
Posted 20 April 2017 - 02:54 PM
Try running your program before RELEASING it. A syntax error isnt exactly something you can overlook.
Goof #5
Posted 20 April 2017 - 02:56 PM
I fixed my code and tested it, it should be goochie now.
before pointing out an error in the code test it first and tell me how to activate the bug.
As Exerro said, this code is not valid lua. It has syntax error(s) which you would need to fix.
Try and run the pastebin program given in the original post and see the syntax error appearing.

Spoiler

So again, you need to test your program before publishing it. If you're asking for help, I am sure someone would be willing to look through for other mistakes at the Ask a Pro section.

EDIT: King was a bit faster than me, so i guess i got ninja'd
Edited on 20 April 2017 - 01:06 PM
KidBrine #6
Posted 20 April 2017 - 11:28 PM
I fixed my code and tested it, it should be goochie now.
before pointing out an error in the code test it first and tell me how to activate the bug.
As Exerro said, this code is not valid lua. It has syntax error(s) which you would need to fix.
Try and run the pastebin program given in the original post and see the syntax error appearing.

Spoiler

So again, you need to test your program before publishing it. If you're asking for help, I am sure someone would be willing to look through for other mistakes at the Ask a Pro section.

EDIT: King was a bit faster than me, so i guess i got ninja'd
Try running your program before RELEASING it. A syntax error isnt exactly something you can overlook.
My program didn't update on pastebin… Sorry about that.
But it's fixed now!
Edited on 20 April 2017 - 11:06 PM
Larry84 #7
Posted 28 April 2017 - 09:48 PM
Cool, that works just fine for me. Nice little API! :)/>
KidBrine #8
Posted 02 May 2017 - 11:37 PM
Cool, that works just fine for me. Nice little API! :)/>
I'm glad you like it! Im late because i thought the topic was dead.
I've noticed that if my programs work well then i get almost no replys, but if there is a problem then i get all sorts of replys.
Dave-ee Jones #9
Posted 10 May 2017 - 06:55 AM
Cool, that works just fine for me. Nice little API! :)/>
I'm glad you like it! Im late because i thought the topic was dead.
I've noticed that if my programs work well then i get almost no replys, but if there is a problem then i get all sorts of replys.

That's the way it goes, even on other programming forumses :)/>