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

Bluetooth: GUI edition released!

Started by Mitchfizz05, 27 June 2013 - 06:17 AM
Mitchfizz05 #1
Posted 27 June 2013 - 08:17 AM
BLUETOOTH: Command line edition! (v1.1)

Bluetooth is a program that allows you to easily share files with your ComputerCraft mates.
I'm trying to make it as similar to real Bluetooth as I can, and so far I'm quite happy with my work.

Note: This program is currently in beta. You may find bugs, if you do, please report them.


FEATURES:
  • Allows you to quickly send files to other computers.
  • Simple and easy parameters.
  • Doesn't have a 24hr limit like using pastebin does (not saying there is anything wrong with pastebin, it's great for releasing stuff to lots of people)
  • Can send any file, even paint files!
PLANNED:
  • Another separate Bluetooth program that has a GUI. Done!
  • A Bluetooth API for developers to send files over Bluetooth.
  • Less bugs!
  • Maybe sending of whole folders. (Maybe - I don't think this isn't possible in real Bluetooth, but it would be useful.)
FOR DEVELOPERS:
If you want to tap into Bluetooth with your own programs, until the Bluetooth API comes, here are what is sent and received when sending/receiving Bluetooth requests.

The sender computer sends, "bluetooth.connect"
The sender computer waits for "bluetooth.accept"
The receiving computer replies, "bluetooth.accept"
The sending computer sends, "bluetooth.filename:<FILE NAME>"

Then the sending of the program begins. The program is sent line by line.

The sending computer sends "bluetooth.file:<FILE LINE>" for each line, while the receiving computer is taking in all these lines and usually would write them to a file.
The sending computer finally sends "bluetooth.done".

The transfer is compete.
Sorry for my terrible explanation.You could also look in the source code to find out yourself how it all goes down.

SCREENSHOTS:
Spoiler




HOW TO GET IT:
Easy!
First you must make sure the server you play on has the HTTP API enabled or if your playing singleplayer your client has the HTTP API enabled.
Then simply type: pastebin get GhP5SqaP bluetooth
You now have bluetooth!

CHANGELOG:

1.0 (UEQsyJUG):
* Initial release.

1.1 (GhP5SqaP):
* File closes after reading it when sending a file.
* Fixed delete mistake.


HOW TO USE IT:
Make sure you have a rednet modem on the right side of your computer and run "bluetooth receive" on the computer you wish to receive the file, then on the sending computer type "bluetooth send <file> <computer ID>".
Using incorrect syntax or typing bluetooth will show the usage.

Thanks. Hope you like it. =)

Also: does anyone know why as I write this post my cursor moves? It's really annoying and causing me to backspace stuff I'm not supposed to.

BLUETOOTH: GUI Edition!
Due to the great response I got for my command line Bluetooth, I instantly went ahead and made… BLUETOOTH: GUI Edition!
It does what the command-line bluetooth does, except this one has a fairly nice GUI (I'm not the best with graphical user interfaces, but I tried.).
It is cross-compatible with the command-line Bluetooth, therefore you can receive a file using the command-line bluetooth and send a file using the GUI bluetooth (or vice-versa).
Run this command on an in-game computer: pastebin get 8c4kCDw0 bluetoothGUI.
Then type "bluetoothGUI"!


Spoiler




(Yeah, I just noticed that bug, "Enter the file you wish to send in the gray box bel"). Opps. I'll fix that later…

Sorry if I made any mistakes on this thread, I was in a rush.
svdragster #2
Posted 27 June 2013 - 09:03 AM
Hey nice job!
Goof #3
Posted 27 June 2013 - 09:21 AM
Also: does anyone know why as I write this post my cursor moves? It's really annoying and causing me to backspace stuff I'm not supposed to.
That also happens to me, when i posts.. I dont know what to do.. imo i think its a bug with the forum script.

Btw.. Really nice Program.
Khento #4
Posted 27 June 2013 - 10:11 AM
Why don't you serialize the file?
Xiretza #5
Posted 27 June 2013 - 03:15 PM
Hey! I'm working on a file transfer program too atm! And no, I won't look at your code, because I want to figure it out myself :)/>
jesusthekiller #6
Posted 28 June 2013 - 07:31 AM
Good to see some clueless with clear, organized code! :D/>

You gave me an idea for next project :ph34r:/>
Mitchfizz05 #7
Posted 28 June 2013 - 10:18 PM
Why don't you serialize the file?
Could, but I like it how it semi-slowly sends the file, I'm trying to replicate real Bluetooth.

Good to see some clueless with clear, organized code! :D/>

You gave me an idea for next project :ph34r:/>
Thanks =D
Hoguesteele #8
Posted 28 June 2013 - 11:47 PM
Hey, I hope you dont mind. I edited this already great program in a few ways that I thought could make it a little better. Now the wireless modem can be placed anywhere on the computer or turtle. When you type "bluetooth" into the shell without any arguements or a modem attached, it runs the printUsage() command right away instead of erroring over the missing modem. And now when you run "bluetooth receive", it first does shell.run("id") then prints, "Waiting for a bluetooth connection…" so that you don't have to check the id of the computer you are sending a file to in addition to running this program.
It's on pastebin as an edit of your code, named as such as well.
link: http://pastebin.com/nBG9h6YL

Also, I would like to state that the ability to place the wireless modem on any side, is code that I took line for line from the gps program that comes with ComputerCraft. Why change something that works perfectly? (Unless that violates some sort of copyright or plagerism law?)
Mitchfizz05 #9
Posted 29 June 2013 - 03:12 AM
Hey, I hope you dont mind. I edited this already great program in a few ways that I thought could make it a little better. Now the wireless modem can be placed anywhere on the computer or turtle. When you type "bluetooth" into the shell without any arguements or a modem attached, it runs the printUsage() command right away instead of erroring over the missing modem. And now when you run "bluetooth receive", it first does shell.run("id") then prints, "Waiting for a bluetooth connection…" so that you don't have to check the id of the computer you are sending a file to in addition to running this program.
It's on pastebin as an edit of your code, named as such as well.
link: http://pastebin.com/nBG9h6YL
I'm fine with people making edits of my program. It makes me quite happy that people are interested, so… thanks. =)

I've been quite happy with the response of my program, and have started working on the GUI version.
Note that I ain't very good with graphical user interfaces, but I'm trying to make this as good as I can.
Lyqyd #10
Posted 29 June 2013 - 02:05 PM
Use the edit button, please.
steel_toed_boot #11
Posted 29 June 2013 - 03:26 PM
Sounds really cool! :D/>
hobo124 #12
Posted 04 July 2013 - 02:16 PM
I'm going to make use of this since im a CC noob, thanks!
UMayBleed #13
Posted 04 July 2013 - 03:26 PM
Nice work! my OS will have a built in File transfer protocol in the Network API. A lot of people seem to be making these types of programs.
albrat #14
Posted 12 July 2013 - 06:19 AM
you could extend the Gui toinclude a directory listing… :D/>


-- function get Dir listing
function Dirlist(folder)
local list = fs.list(folder)
return list
end

returns a table index of the folder.
to call the function list = Dirlist(foldename) - Returns a table of file names. list[1] , list [2] .. etc.

you could list the files with numbers, then have a prompt input file number… then the inputted number calls directly from the table (after a limits check) eg. if input >= 1 or <= #list then … else print("bad number") end

then you don't have to check filenames (filename mis- spellings) . hehe
Mitchfizz05 #15
Posted 13 July 2013 - 04:18 AM
you could extend the Gui toinclude a directory listing… :D/>


-- function get Dir listing
function Dirlist(folder)
local list = fs.list(folder)
return list
end

returns a table index of the folder.
to call the function list = Dirlist(foldename) - Returns a table of file names. list[1] , list [2] .. etc.

you could list the files with numbers, then have a prompt input file number… then the inputted number calls directly from the table (after a limits check) eg. if input >= 1 or <= #list then … else print("bad number") end

then you don't have to check filenames (filename mis- spellings) . hehe

I might add a clickable file selection type thing.

( also, cool signature. :P/> )
LDDestroier #16
Posted 30 October 2014 - 02:19 AM
Hey, I saw this post and I was relieved to find a GOOD file transfer program! Although, I did see some flaws.

1. It does not seek for rednet modems, causing errors on pocket computers
2. It was unnecessarily slow.

I took the time to rewrite it a bit, and here is the pastebin of the modified bluetooth:

pastebin get 8cqWivAE bt

I hope you like the changes!