色の夢

Create Stuff Easy!

How good this is?   

2 members have voted

  1. 1. How good this is?

    • 10/10**********
      0
    • 11/10***********
      0
    • 12/10************
      0
    • 13/10*************
      0
    • 14/10**************
      0
    • 15/10***************
      0
    • 17/10****************
      0
    • 18/10*****************
      0
    • 19/10******************
      0
    • 20/10*******************


Recommended Posts

Can't connect... and your English is poor.


"Try to get a better understanding of things before making your judgement." -Khan, Metro 2033

 

Share this post


Link to post
Share on other sites

I wasn't able to create, mang. I'll give it a 20/10******************* for the effort, though.

Share this post


Link to post
Share on other sites

So I'm not the only one having trouble. Looks like the TC may be having server trouble.

 

Anyway, this looks like it's supposed to be a MUD. It's a multiplayer online text-only game, in which players can create characters and areas through a combination of writing and coding. You can find some other MUDs through mudconnect.com or mudstats.com, if you're interested. Both sites have some MLP games. Pony characters might not be so welcome in non-pony oriented games (although RetroMUD is hard fantasy, and will allow unicorn characters).

Share this post


Link to post
Share on other sites

Sorry guys, I got bored. There's some bugs so it'll crash randomly. I'll leave it running one more time until it crashes. So have fun until then if you see this in time.

 

Here's the source if anyone wants to host it themselves. Just "node whateveryounamethefile.js " and make a file called save.txt in the same directory as it, to save to. It's shit, but w/e guys. Runs on port 8888.

var net = require('net');

var sockets = [];

/*
* Cleans the input of carriage return, newline
*/
function cleanInput(data) {
return data.toString().replace(/(\r\n|\n|\r)/gm,"");
}

/*
* Method executed when data is received from a socket
*/
function receiveData(socket, data) {
var cleanData = cleanInput(data);
if(cleanData == "look"){
	socket.write( game.look(socket.gameLocation) );
		console.log(game.ents);

}else if(cleanData.substring(0,6) == "enter "){

	if(game.ents[cleanData.substring(6)]){
		socket.gameLocation = cleanData.substring(6);
		socket.write( game.look(socket.gameLocation) );
	}else{
			for(var i=0; i					if(game.ents[game.ents[socket.gameLocation].contains[i]].name==cleanData.substring(6)){
					socket.gameLocation = game.ents[socket.gameLocation].contains[i];
					socket.write( game.look(socket.gameLocation) );
					return(0);
				}
			}
		}

}else if(cleanData == "exit"){
	socket.gameLocation = game.ents[socket.gameLocation].parent;
	socket.write( game.look(socket.gameLocation) );
}else if(cleanData.substring(0,7) == "create "){
	socket.write(chatCreateEnt(socket.gameLocation, cleanData.substring(7)));
}else if(cleanData.substring(0,4) == "del "){
	socket.write(chatDelEnt( socket.gameLocation,cleanData.substring(4)) );
}else if(cleanData == "save"){
	pie = JSON.stringify(game.ents);
	console.log(pie);
	fs = require('fs');
	fs.writeFile("./save.txt",pie,function (err){
		if(err) throw err;
		console.log("It's saved!");
	});
}


if(cleanData === "@quit") {
	socket.end('Goodbye!\n\r');
}

}

//chat command delete entity
function chatDelEnt(parentId,data){
//if it's an ent id, check if it's in the parent and if so, delete it.
if(game.ents[data]){
	for(var i=0; i			if(game.ents[parentId].contains[i] == data){
			game.delEnt(data);
			return("Deleted it, nigga.\n\r");
		}
	}
}else{
	for(var i=0; i			if(game.ents[game.ents[parentId].contains[i]]){
			if(game.ents[game.ents[parentId].contains[i]].name == data){
				game.delEnt(game.ents[parentId].contains[i]);
				return("Deleted it, nigga.\n\r");
			}
		}
	}
}
return("nigga pls\n\r");

}	

//chat command create entity
function chatCreateEnt(parentId,data){
game.addEnt(parentId, data);
return("You create a "+data+".\n\r");
}

/*
* Method executed when a socket ends
*/
function closeSocket(socket) {
var i = sockets.indexOf(socket);
if (i != -1) {
	sockets.splice(i, 1);
}
}

/*
* Callback method executed when a new TCP socket is opened.
*/
function newSocket(socket) {
console.log("new socket: "+socket.remoteAddress);
socket.setTimeout(2*60*1000);
socket.gameLocation = 0;
sockets.push(socket);
socket.write("Welcome!\n\rType \u001B[1;32mcreate\u001B[0;0m ___ to create something.\n\rType \u001B[1;32mdel\u001B[0;0m ___ or del # to delete something\n\rType \u001B[1;32mlook\u001B[0;0m to look.\n\rType \u001B[1;32menter\u001B[0;0m ____ or enter # to enter that thing.\n\rType \u001B[1;32mexit\u001B[0;0m to exit the place you're in.\n\rType \u001B[1;32m@quit\u001B[0;0m to exit the game\n\rType \u001B[1;32msave\u001B[0;0m to save the server. There's no autosave. If the server crashes and no one's saved recently, you're \u001B[1;32mfucked\u001B[0;0m!\n\r");
socket.write( game.look(socket.gameLocation) );
socket.on('data', function(data) {
	receiveData(socket, data);
})
socket.on('end', function() {
	console.log("closing socket"+socket.remoteAddress);
	closeSocket(socket);
})
}

function ent(id, parent, name, creator){
this.id=id;
this.name=name;
this.creator=creator;
this.parent=parent;
this.contains=[];
}

function Game(){
}

Game.prototype.init = function(){
fs = require('fs');
var saveFile;
fs.readFile("./save.txt", function read(err, data){
	if(err){
		throw err;
	}
	saveFile = data;
	game.ents = JSON.parse(saveFile);
	console.log("loaded save file");
	console.log(game.ents);
});
//this.ents = [new ent(0,0,"The Beginning","God")];
}

Game.prototype.addEnt = function(parent, name){

for(var i=0; i		if(this.ents[i]==null){
		this.ents[i]=new ent(i, parent, name, "anon");
		this.ents[parent].contains.push(i)
		return(i)
	}
}
this.ents[parent].contains.push(this.ents.length);
this.ents.push(new ent(this.ents.length,parent,name,"anon"));

}

Game.prototype.delEnt = function(id){
//delete the items inside
if(this.ents[id].contains.length){
	for(var i=0; i			this.delEnt(this.ents[id].contains[i]);
	}
}
//delete it from the parent's contains list.
for(var i=0; i		if(this.ents[this.ents[id].parent].contains[i] == id){
		this.ents[this.ents[id].parent].contains.splice(i,1);
	}
}
this.ents[id]=null;
//this.ents.splice(id,1);
}

Game.prototype.look = function(id){
locationString = "You are in "+this.ents[id].name+". You see ";
for(var i=0; i		locStr="["+this.ents[id].contains[i]+"]"+this.ents[this.ents[id].contains[i]].name+" ";
	locationString=locationString.concat(locStr);
}
return(locationString+".\n\r");
}

// Create a new server and provide a callback for when a connection occurs
var server = net.createServer(newSocket);

// Listen on port 8888
server.listen(8888);

game = new Game();

game.init();

 

If there's enough interest I could host this.

 

It's really not worth it. I got bored before adding anything cool to it. Basically all you can do now is create, delete, enter, and look. I don't think any particular features would make this worth playing.

 

ex: create Dr Pepper

enter Dr Pepper

create My Tupper

create Grass Field

create lake

look

"You see My Tupper, Grass Field, and lake"

enter lake

create a boat.

 

 

 

Entire 'game' is that. While making it, I thought it might be fun, but SURVEY SAYS: nope!


Will the BBB please buy my guide. [advertising link scrubbed]

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.