Giter Club home page Giter Club logo

growtopia.js's Introduction

GTPS Wrapper

Growtopia.js is the first ever Growtopia Private Server coded with NodeJS. Inspired by Growtopia Noob's Private Server This uses it's own C++ Code. Packet creation, send world, generate world, packet decoding is done on node.js. Packet sending is done in C++ though.

Running

You would have to make a sepearate .js file and copy the example below.
Install the required packages first by doing npm install.
For the webserver, simply run node web.js on a separate terminal/cmd/shell, or run your own! (if you've already set it up)
You would also need enmap, you can simply run npm install enmap to install it. If you receive an error about node-gyp, kindly do npm install node-gyp -g. If it still won't install, kindly ask support on our discord

Example

const { Main } = require('./index.js');
const Server = new Main({
  port: 17091, // note: this is the default value, you can not include this if you'd like.
  channels: 32, // note: this is the default value, you can not include this if you'd like.
  peers: 2, // note: this is the default value, you can not include this if you'd like.
  bandwith: {
    incoming: 0, // note: this is the default value, you can not include this if you'd like.
    outgoing: 0 // note: this is the default value, you can not include this if you'd like.
  },
  location: 'items.dat', // note this is the default value, you can not include this if you'd like.
  cdn: '0098/CDNContent61/cache/', // note: this is the default value, you can not include this if you'd like.
  commandsDir: `${__dirname}/src/commands`, // note: this is the default value, you can not include this if you'd like
  secretKey: 'growtopia.js' // The secret key to use to encrypt passwords, PLEASE CHANGE THIS AND DO NOT TELL ANYONE YOU DON'T TRUST
});

Server.Host.init();
Server.Host.create();

Server.on('connect', (peerid) => console.log(`A client connected with peer ${peerid}`));
Server.on('receive', (packet, peerid) => {
  // do stuff when you receive data from the server
});
Server.on('disconnect', (peerid) => console.log(`A client disconnected with peer ${peerid}`));

Server.Host.start()

Creating Commands

In Growtopia.js, you can easily create commands. You would need to create a file for it inside the given commands directory, or by default src/commands. It must have the .js extension. After creating you would need to make an object that would contain the properties: name and the function run. The run function has 3 parameters, main (the one that has access to most/all methods), arguments (an array of strings which are the given arguments for the command, or none if a player didn't give), peerid (the id of the peer that ran the command, can be used to send data to). p would be the PacketCreator which you can create packets with. Here is an example of a command:

module.exports = {
  name: 'hello',
  requiredPerms: 0,
  run: function(main, arguments, peerid, p) {
    p.create()
      .string('OnConsoleMessage')
      .string(`Hello ${main.players.get(peerid).displayName}`)
      .end();

    main.Packet.sendPacket(peerid, p.return().data, p.return().len);
    p.reconstruct(); // this is needed so that other features that will use the same PacketCreator instance can create/recreate packets.
  }
};

Based on this example, it would say Hello yourNameHere. Required perms is not needed as they can be omitted since the default is undefined. You can check the Constants.Permissions object to see what are the available permissions. That's how you can create your commands. No need to handle how they are loaded as it is handled upon start. When modifying a command, you would need to restart the server. This will be fixed, but not soon as it's not very important.

Docs

Our docs are automaticlly made. They're in /docs.

TODO

  • Update Docs
  • Inventory
  • Disconnection Issues Fixed
  • Plant Trees
  • Respawn
  • Signs/Doors
  • ???

This will be changed if we found more stuff to do.

growtopia.js's People

Contributors

lukeacat avatar syn9673 avatar

Stargazers

RevyanAldy avatar Muhammad Kevin avatar Muhammad Yusuf avatar

Watchers

James Cloos avatar

Forkers

jadlionhd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.