SWAP level hosting

So im working on a level editor for SWAP, and right now im to the point where I need to figure out a way for people to host the levels, so that other people can download them. So like a website they go to with a list of all these user made levels that they can download and play. The most ideal way would to have a menu of sorts inside the game itself that lets you pick levels to download play, but my second way is to just have it on a dedicated website.

How would I go about doing this?
I know first I need to find some sort of host to host the files, and then some how allow others to upload files. within the website.

So I have an idea, what if i just had it so people use there own file hosts an post the links, like on a forum or something like that?

EDIT: also is there way to have maybe a script that exports the level or .blend out, and automatically bundle it with a self extractor?

Create a forum would be my suggestion, they’re searchable, and can have attachments. Depending on the level of your experience with web hosting will effect what you do:

  • You could make a site at x10 hosting (free, if you log on once a month). This is a complete site, where you can have image galleries, normal pages etc. It is quite a bit of work to set up, but works nicely. (deepspace.x10.mx is my website, hosted at x10). X10 claims to let you have an infinite storage even on a free account, but for me (after a year or so) it seems to have capped itself at 1gb, not that I’m anywhere near there, and chances are, even for hosting levels, you won’t either.
  • You could use forumotion, or freeforums. Both are free. I haven’t used either, but imagine they’d work fine.

The default phpbb forum (which is what mostly everyone uses) is almost exactly ready. You’d just have to allow guests to download attachments, and possibly allow uploading of blends (or you could just tell people to put them in zips).

Spam is always a problem, but there are measures you can take. I haven’t got a spammer for a few months now.

If you go via X10 you could have a script that generates a list of levels into a text file, and keeps it on the web.
Or you could give the game the necessary code to access the web, and download the files.

I would recommend simply adding a button that takes you to the level sub-forum though.

Quite a separate way would be to set up a FTP host. This is less user-browsable and searchable, but should be easier for the game to access and download.
I have little experience with FTP though, so I can’t tell you specifics.

Just a thought, you could use a group here at BA?

thanks, does x10 come with a built in CMS or do you need to install your own?

Im currently hosting the main SWAP website on zymic, witch is similar to x10.

Having the game connect to a ftp server and bring up a nice UI with all the levels, would be the best case, but its hard to do.

if it is block-based, you can make text files saving the positions and types of blocks, so you can share those “encrypted” files , so your game loads them as levels, and they would be way more compact(less storage space!)
however this is just and idea, i have absolutely no idea on how to do it xD

Actually that’s really interesting, so basically you would have one .blend file that, when it recievs the text file, it morphs everything around?

What do you mean by blocks?

well, a block based game, like minecraft…
where everything is made of blocks

Oh I thought you meant something else, like instructions, that tell each object group in the game where to appear, basically each time the level is loaded,

like red green blue, when loaded, instructions say to put red here, green over there, and blue right there, (if that makes sense)

yep thats what i tried to say :smiley:
you have the example of minecraft:
minecraft world, assigns an ID to each space unit (in this case blocks)
-if that ID is 0 the generator will generate air
-if that ID is 1 it will generate stone
-if that ID is 2 it will generate grass
-and so on

you can create something quite like that, where the game checks for an ID on each space unit and generates the map according to that

if this is hard to understand please let me know it!

or you can just create your maps on .blend files and spread them everywere lol

The problem with that method is that blender is better at rendering 100 10,000 poly objects that 10,000 100 poly objects.
I would stick to importing blends as level files, as they contain object information without you needing to check it’s validity, move a vertex or two, or anything.
As long as you have good documentation (and possibly a script) for adding spawn points, everything should be fine. It also allows custom textures etc.

X10 comes with ‘CPanel’ (presumably control panel), which has a file browser, script installation (for galleries and forums), and some web authoring tools. I coded my site by hand, because I’m familiar with HTML, and can’t be bothered learning a new tool, but you can use any tool you like to make the actual site. I imagine your current host will be fine, if you can install phpbb. No reason to change.

Setting up FTP from x10 isn’t hard, and I don’t imagine it’s much different in zymic. I just had to tell it which folder, give it a user name and password, and then that was an FTP directory.
As to the blender/game end, python does have a library for it, and it doesn’t look to hard to use.
Being interested in setting up a similar system myself, I’ll have a play over the next week or two and see if I can figure anything out.

One thing that you have to be careful of is sending connections every frame. Internet hosts don’t like 60 connections from the same machine to be made every second. When I made an IRC bot, I discovered a few things: Close all connections. Don’t make more than about 5 connection’s in a minute.
I would structure the code with an ‘init’ function. The first time it runs, you create the connection and get/display a file list. The next time you’ve made your selection, and it downloads it.

You can read the bottom of the post (my own python ramblings) or you can see a simple script over here.

Like any other internet protocool, FTP will close if you are inactive to long. You may have to re-open the connection, or respond to the servers pings (in this case they are “NOOP”) Send a ‘NOOP’ every 5 minutes or so and you should be fine.

I’ve no idea if that helped, confused you, or if you’ve discarded this idea completely. I’ll stop typing before I say something stupid.


So you’d set up a basic connection with:

import ftplib

username = user
password = pass

ftphost = ftplib.FTP('ftp://your url')
ftphost.login(username, password)

Then to access it you can either send the command via a string, or via a dedicated python function:

fileList = ftphost.retrlines('LIST') #LIST is a standard FTP comand. See the wikipedia page on FTP to see what others are


fileList = ftphost.nlst()
print (fileList)

From there you can search through the fileList and when you find your file you can get it with something like:

fileToWriteTo = 'path/to/local/file'

reply = ftpHost.retrbinary('RETY '+fileName, open(fileToWriteTo, 'wb').write)
if reply = '226 Transfer Complete':
    print (reply)
    print ("sdfgeoff guessed his code wrongly")

I haven’t tested any of this, and it’s written straight from the documentation. I probably missed something, so don’t kill me if it doesn’t work!
I’ll actually try this tomorrow. (I just need somewhere to store my first thoughts of the code, not being on my main PC, and here works fine).

so this would be attached to some sort of UI that when you click a button it loads another window that lets you select files off the ftp server from zymic in this case?

Nope, that could be run straight from the game itself, with a bit of planning.

hmm, its a tall task…

I was thinking of for now doing a website that runs on word-press CMS and I found a bbpress plugin, for forums, and have people upload there levels into specific forum thread categories. And then on the main page have a featured section or most popular section.

That works