Submit templates for repl.it/templates here.

← Back to all posts
A simple template for creating NodeJs RPG games
sojs (341)

Setting Up

To set up your dungeon, you need to do 2 very simple things. Number 1: Fork the repl provided. Number 2: run it.
Your dungeon is now set up.

Editing the dungeon

To edit the content of the dungeon, such as the rooms, where you start, the monsters in it, the items and weapons, and the player, you use premade functions made in dunr.js. These functions build the dungeon.

Function 1: dungeon.addPath()

This function adds a room to the dungeon. It takes 5 parameters.
1: The name of the room, such as "room1" or "the_dark_room"
2: A description of the room. "A dark room with a path leading north"
3: The rooms paths, in JSON format e.g

{"north":"room23","south":"room32"}

There is no northwest, or anything like that. Just North, south, east, and west.
4: The items in the room, in an array: ["chicken","healing_potion"] No spaces in item, weapon, monster, or room names.
5: The weapons in the room, same as items.
That is how you create a room. Remember to create all rooms that you use, otherwise it will throw an error when you try to enter it.

function 2: dungeon.addItem();

This takes 5 parameters, the items name, it's type (health, gold, strength, or all,which adds to all of the above), the third parameter judges by how much the type goes up by, a description, which shows when you use the item, and it's durability, as in how many times the user can use the item. Here is an example:

  dungeon.addItem("chicken","health",10,"A chicken",1);

This will create an item call "chicken", which, when used, adds 10 to the users health.
That is how you add items.

Adding Weapons with dungeon.addWeapon();

This one takes only three, it's name, how much it harms when used, and it's durability.

  dungeon.addWeapon("stick",10,100);

Adding Monsters

  dungeon.createMonster(100,100,[],"orc",["room3"],10);

The first parameter, is it's health, the second, how much it can harm people, the third, what it drops (which you automatically pick up). The fourth parameter is the monsters name, and the 5th, what rooms it appear in. The last parameter is the monsters dexterity.

Dev note: you must have an equiped weapon to attack a monster

The last function, setting up the player.

This function sets up the player, it is called with dungeon.player();
Here are its parameters:
1: Health
2: dexterity
3:Wisdom (used for pleading to the gods)
4: Strength
5: Gold
6: The players name
These are all the functions used to run the dungeon. A simple dungeon is found in create.js (which is the only file that you should edit). Have fun! Feel free to comment with your dungeons!

Comments
hotnewtop
sojs (341)

Hello everyone!! @Warhawk947 @xolyon @pythonier @viper2211 @Nanowrimoijk @adityaru @mkhoi @wulv @acer123 @SilentShadowBla @PYer and @Highwayman. I just want to say that YAAAAY, all bugs have been fixed, and with extensive testing of all the templates functionality. Remember to put in all the values in the correct order (when using the template), without this, your game may crash :). Thank you for upvoting! :)

Viper2211 (85)

Yay! This is a great template and I’m happy to see it [email protected]

Highwayman (1482)

@sojs I’m so late to the party ;-;
Anyways..

YAYY!!!

:)

Highwayman (1482)

I’m so mad rn why hasn’t anyone else upvoted this this is literally the best template here. Ya’ll are dumb.

sojs (341)

@Highwayman Thanks man. That's what I've been telling everybody.

sojs (341)

@Highwayman Could you please spread that around. I would appreciate it. Thanks!

Highwayman (1482)

@sojs hm once I figure out how yes of course gladly :)

sojs (341)

@Highwayman Thank you. Do you have any templates?

Highwayman (1482)

@sojs no not yet sadly. I’m not a very good coder lol I just answer questions well I guess.

PYer (4010)

Then @Highwayman, comes advertises @sojs's on my post. Not sure if it's a joke or not.

wulv (61)

Great template! But I think I've spotted a bug:

sojs (341)

@wulv I fixed that. Forgot to define something. Thank you for your feedback!