node-tserver

1.0.2 • Public • Published

Terraria Server

Fast setup

Ngrok routing

Auto-save system

Note

• You might need a 100mb free storage for installation and setup of terraria server

• Recommended for 2gb+ ram for less lag

• Your progress will be loss if you dont save it

• Terraria Files is saved at your project root or project cwd

Soon to make

  • Server Plugins
  • User authorization system

Fixes

  • Terraria Folder not loading and saving
  • Commands not working

Documentation

  • Creating your first Server is not that hard
  • You just need to have 100mb free in your storage
  • To create your server, follow this example
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system

  server: { // most important setup

    ngrok: { // if you dont want ngrok, just dont put it
      // go here to specify the options of ngrok, "https://npmjs.com/package/ngrok#Options"
      authtoken: 'my ngrok auth token',
      region: 'eu'
    },

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})
  • A setup without ngrok
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system
  
  server: { // most important setup

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})
  • Start your server with
server.start()
  • TerrariaServer have some events too
// The 'started' event will fire when the server started
server.on('started', async(control, host) => {
  console.log(host) // Host only exists if you use ngrok

  control.save() // saves your progress

  control.send('say Hi Im Sending This') // sends command in the terminal

  control.close() // stop your server with save
})

// The 'connected' event will fire if there is a player joined in your server
server.on('connected', async(user) => {
  console.log('User Joined '+user)
})

// The 'disconnected' event will fire if there is a player leaved in your server
server.on('disconnected', async(user) => {
  console.log('User Leaved '+user)
})

// The 'chat' event will fire when a player sends a message in chats
server.on('chat', async(user, msg, reply) => {
  reply(user+' said '+msg) // the reply function will send message in the chat
})

Want to create commands?

  • Follow this setup if you want a command!
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system

  server: { // most important setup

    ngrok: { // if you dont want ngrok, just dont put it
      // go here to specify the options of ngrok, "https://npmjs.com/package/ngrok#Options"
      authtoken: 'my ngrok auth token',
      region: 'eu'
    },

    // here how you enable it
    command: { // enable it by doing this
      prefix: "/" // put the prefix you want here
    },
    // just add this 3 lines on your options

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})

now everytime a user chats a message that starts with "/", it will be specified as a command

thats gonna fire the "command" event

server.on('command', cmd => {
  // it will return a "cmd" object

  console.log(cmd)

  // cmd returns an object
  // cmd.command - this is the name of the command that was runned
  // cmd.arguments - all arguments that was recieve from the command
  // cmd.control - returns the control methods from the server
  // cmd.message - returns the full message object
})

I created built-in commands

- time (dawn, noon, dusk, midnight) : Change the time status
- admin add <username> : adds a user to the admins
- admin delete <username> : removes a user to the admins
- banlist add <username> : adds a user to the banlist 
- banlist delete <username> : removes a user to the banlist

Note: Only users you put in admins, can access command!

...

I used dedicated server than TShock is because some TShock versions doesnt work in linux (and ofc in Replit)

Yeah the other one is broken

Links Used

A Bug?

• Currently testing so

• Email me at: filipinoakoyoww@gmail.com

Thanks For Downloading 💛

Package Sidebar

Install

npm i node-tserver

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

42.7 kB

Total Files

22

Last publish

Collaborators

  • filipinoakoyoutube