Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Works-In-Progress (http://www.alice.org/community/forumdisplay.php?f=14)
-   -   It was here first (http://www.alice.org/community/showthread.php?t=4548)

zonedabone 06-05-2010 06:06 PM

It was here first
 
1 Attachment(s)
This thread is by zonedabone, the FIRST person to write file access programs in Alice using Jython. (Tell me if you want to argue.)

Ok. I've been on hiatus working on this and that IRL. I decided today that I'd work on multiplayer through ftp. Anyway, I'm working on a set of routines that will let you easily upload files to ftp servers, and then download and read them from any computer. I've set aside a section of my IP for testing. The details, which will bring you to a folder of happyness, limited to 1 MB will be given to those who give me a reason for experiments.

Anyway, here's the code for the ftp currently. It's pretty mcuh done, minus a few extra methods that I added in the demo.
[PHP]
connected = false
from ftplib import FTP
def connect(host,username,password):
global ftp
global connected
if connected == false:
ftp = FTP(host,username,password)
connected = true
def upload(filename,name):
global ftp
global connected
if connected == true:
test = open(filename, 'r')
ftp.storbinary('STOR ' + name, test)
test.close()
def download(filename,path):
global ftp
global connected
if connected == true:
dir = open(path, 'w')
file = ftp.retrbinary('RETR ' + filename, dir.write)
dir.close()
def close():
global ftp
global connected
if connected == true:
ftp.quit()
connected = false
def getwelcome():
global ftp
global connected
if connected == true:
world.output = ftp.getwelcome()
def rename(oldfile,newfile):
global ftp
global connected
if connected == true:
ftp.rename(oldfile,newfile)
def delete(file):
global ftp
global connected
if connected == true:
ftp.delete(file)
def setdir(dir):
global ftp
global connected
if connected == true:
ftp.cwd(dir)
def makedir(dir):
global ftp
global connected
if connected == true:
mkd(dir)
def deldir(dir):
global ftp
global connected
if connected == true:
ftp.rmd(dir)
[/PHP]With this code, I created a world that allows two computers to communicate. In fact, all computers usng this program will see what others are saying. Enjoy! Pressing U lets you add your message to it. Now with history thanks to Dameria's suggstion! New features! C = change user! D = disconnect.
[ATTACH]3028[/ATTACH]

If you don't have an account and can't download the file, it is also available on wikisend:
[URL="http://wikisend.com/download/472094/intercom.a2w"]intercom.a2w[/URL]

Dameria 06-06-2010 09:19 AM

This is good, but there are a lot of problems. One major problem is that it freezes for a few seconds until it finally shows the text, and altogether the whole program is very slow. Also, you should make it so that it is more like a chatroom where there is a list of, lets say, the previous 10 comments by people instead of only 1 comment that can be changed by anyone.

zonedabone 06-06-2010 09:36 AM

Why it is...
 
During the beginning, with the grey stuff, that's Alice connecting to the FTP server. About the chat-room idea, it's possible, but not easy. Sadly, there's no way to get rid of the wait at the beginning. Think of it as connecting to server.

Dameria 06-06-2010 01:35 PM

It is a little better now, but I have another suggestion. Right now, it just creates a new line of code in the same 3d text whenever someone new talks. Maybe you can have a set list of 15 3d texts, and whenever someone says something new, it just assigns the string from the 3d text above to the one below, I think you can do this in a simple for all in order loop. You can have each string be sent to the server and saved as a string there, and then when the server accesses the other people's computers it assigns each of the strings from the sever to the strings in the program of the individual computer.

Also maybe you can have a list on the side showing which users are on so we know who is on.

zonedabone 06-06-2010 02:40 PM

Hmm.
 
Actually, the server does nothing. It's just everyone saving a file on the server. With the login list thing, the problem is that people can exit the program without logging out. At first, I tried having a list of texts, but it was really glitchy.:(

Dameria 06-06-2010 05:45 PM

Another suggesting (sorry for posting so many times), can you add a simple alert noise for whenever somebody enters the chatroom or talks? So that we can leave up our Alice worlds and do something else, and when somebody enters the chatroom we can hear the alert and start talking to them.

zonedabone 06-06-2010 06:06 PM

Yeahh. I was thinking about that. It'll be in the next version, but right now just found out how to hack alice, so I'm making a list of every hack code in there!:D

Niteshifter 06-07-2010 12:36 AM

A suggestion to remove some redundancies is to replace the "if connected == true:" lines with "if connected:" and the "if connected == false:" with "if not connected:".

Using '==' or '!=' condition statements with boolean types can lead to the program to be slower than it can actually go since it's going through more (lower level) lines when it could easily skip it all ;).

zonedabone 06-09-2010 08:24 PM

[QUOTE=Niteshifter;22059]A suggestion to remove some redundancies is to replace the "if connected == true:" lines with "if connected:" and the "if connected == false:" with "if not connected:".

Using '==' or '!=' condition statements with boolean types can lead to the program to be slower than it can actually go since it's going through more (lower level) lines when it could easily skip it all ;).[/QUOTE]

Yeah. It's not the greatest code, but it works. I'll start working on this code once I've got the new system set up. It involves a constantly running server to keep track of which peoples are on, and then alert people and all that other wierd stuffs.

noahx23 06-10-2010 12:00 PM

wow this works pretty well, though the problem I had was that if someone wrote a large comment then it wouldn't it wouldn't fit onto the screen. But other than that nice job:D


All times are GMT -5. The time now is 06:39 AM.

Copyright ©2018, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.