1.2.10 • Published 9 months ago

rptd-core v1.2.10

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

rptd-core v1.2.10

rptd-core is a package that allows for generating ruptured levels using code

you can see he source code on github here: rptd-core

Installation

The only pre-requisite is that you have a version of node.js installed.

Then you can create a new project:

npm init

and install the package:

npm install rptd-core

Usage

// import the components
const { jsonUtility, Level, Path } = require('rptd-core')
// create a new level
const level = new Level({ LevelName: 'Example Level' })
// add a new section
level.createSection({ LevelBounds:{ x:-100, y:100, z:100, w:-100 }})

Now you can add tiles and prefabs using level.addTile(...), level.addBGTile(...) etc. (more documentation on all these function below)

Finally you can write the level to a file:

jsonUtility.writeLevelToFile(level, './example_level.json')

Note: it is possible to write directly to a level in your Ruptured levels folder however this is not reccomended if you have the level editor open as it can cause the level loading to break untill you restart the game

Documentation

This is a temporary location for the documentation but it will remain here untill I have time to make an actuall website

jsonUtility

This object contains some helper functions for reading and writing json files and levels

functions

nameparamsreturnsdescription
createLevelFromFileabsoluteFilePathLevel objectReads a pre-existing ruptured level from a json file converts it to a Level object.
writeLevelToFileLevelObject, filePathvoidWrites the given level data to a json file that can be imported into Ruptured. Prints the number of tiles and entities in the level.

Level

A class that contains all of the data for a Ruptured level, as well as many functions for adding tiles and prefabs. Can be constructed directly using new or generated using jsonUtility.createLevelFromFile(path).

properties

namedescription
nextFreeChannelContains the lowest value channel that is not being used

constructor

Takes an object with the following properties (see rptd-core/examples to see how this works):

paramdefaultdescription
LevelName""Name of the level
Creator""Name of level creator
Description""Level description
Music1Level music
Slot0Gun-1Default gun in the first slot
Slot1Gun-1Default gun in the second slot
Slot2Gun-1Default gun in the third slot
InitialHealth5Default max health of the player
InitialEnergy30Default max energy

methods

All of the following methods take an object with the listed properties as a parameter, see rptd-core/examples to see examples

Level meta data methods

setLevelData({ })

Takes the same params as the constructor, and defaults to the current value of those properties

createSection({ })

Creates a new section in the level

Sections are given ids based on the order they are added, starting at 0

paramdefaultdescription
Name""Section name
Music1Section music
LevelBounds{x: 0, y: 0, z: 0, w: 0}An object containing the x = left wall, y = right wall, z = top wall, w = bottom wall
spawnPointX0X coord of the players default spawn point
spawnPointY0Y coord of the players default spawn point

addPath({ })

Adds a path object to the specified section

paramdefaultdescription
sectionId0Section to add the path to
pathInstance of the Path class

Tile utils

addTile({ })

Adds a tile on the specified section and layer

paramdefaultdescription
sectionId0Section to add the tile on
ID0Id of the tile to be added
layer"T0"Layer to add the tile on can be one of ["T0", "D", "BG0", "SS", "H", "M"], see Apendices for what each of these mean
xx position of the tile
yy position of the tile

general methods

addPrefab({ })

note: this function is used under the hood by all prefab utility methods, and it is not reccomended to use this directly, unless there is not yet an implemented method for the desired prefab

Creates a prefab with the specified parameters

paramdefaultdescription
sectionId0Section to add prefab in
IDId of desired prefab
xx position of prefab
yy position of prefab
Properties{}Entity specific properties

addMovingPlatform({ })

General function for adding prefabs that can move along a path

paramdefaultdescription
sectionId0Section to add the prefab to
ID4Id of the platform type, the default (4) is what the game calls 'moving platform'
xx position of the prefab
yy position of the prefab
Size{x: 1, y: 1}An object containing the size of the moving platform
Channel-2Channel of the platform (see Appendices for more info), does not support contolling if a platform moves or not
PathEnabledfalseWeather or not the platform follows a path
PathID0Id of the path to follow
InitialPointID0Point along the path to start at
Speed3Speed of the plaform in tiles per second
ReversedfalseWeather or not the platform follows the path in reverse
PauseDuration0Amount of time that the platform pauses at each point

addLogicGate({ })

General function for adding logic gates, not reccommended to use directly (see Logic gate methods)

returns the channels that were used as an object

see rptd-core/examples/gateExample.js for an example

paramdefaultdescription
sectionID0Section to add the logic gate in
IDid of the gate type
xx position of the gate
yy position of the gate
Channels{ }Object containing the channels of the gate
Properties{ }Any other properties of the gate

prefab utils

addBooster({ })

paramdefaultdescription
sectionId0Section to add the prefab to
xx position of the booster
yy position of the booster
Strength30Strength of the booster in tiles per second
Channel-2Channel of the prefab (see Appendices for more info)
StartActivetrueWeather or not the booster is on when the level loads
Direction00 is up, 1 is left, 2 is down, 3 is right

addButton({ })

paramdefaultdescription
sectionId0Section to add the button to
xx position of the button
yy position of the button
Channel-2Channel of the booster (see Appendices for more info)

addCheckPoint({ })

paramdefaultdescription
sectionId0Section to add the check point to
xx position of the check point
yy position of the check point
isLevelEndfalseWeather or not this checkpoint is a level end trigger

addCrate({ })

paramdefaultdescription
sectionId0Section to add the crate to
xx position of the crate
yy position of the crate

moving platform prefabs

addToggleWall({ })

General function for adding prefabs that can move along a path

paramdefaultdescription
sectionId0Section to add the prefab to
xx position of the prefab
yy position of the prefab
Size{x: 1, y: 1}An object containing the size of the moving platform
Channel-2Channel of the platform (see Appendices for more info), does not support contolling if a platform moves or not
PathEnabledfalseWeather or not the platform follows a path
PathID0Id of the path to follow
InitialPointID0Point along the path to start at
Speed3Speed of the plaform in tiles per second
ReversedfalseWeather or not the platform follows the path in reverse
PauseDuration0Amount of time that the platform pauses at each point

Logic gate methods

addAndGate({ }),addOrGate({ }),addXorGate({ })

Functions for adding and, or, and xor, they all have the same parameters returns the channels that were used as an object (eg: { InChannel1: 3, InChannel2: 4, OutChannel1: 5 })

paramdefaultdescription
sectionID0Section to add the logic gate in
xx position of the gate
yy position of the gate
InChannel1-2First input channel
InChannel2-2Second input channel
OutChannel1-2Output channel

addNotGate({ })

Function for adding not gates returns the channels that were used as an object (eg: { InChannel1: 3, OutChannel1: 4 })

paramdefaultdescription
sectionID0Section to add the logic gate in
xx position of the gate
yy position of the gate
InChannel1-2First input channel
OutChannel1-2Output channel

addLatchGate({ })

Function for adding latches and t-flip-flops (TFF) returns the channels that were used as an object (eg: { OnChannel: 11, OffChannel: 12, OutChannel1: 13})

paramdefaultdescription
sectionID0Section to add the logic gate in
xx position of the gate
yy position of the gate
OnChannel-2On input channel
OffChannel-2Off input channel
OutChannel1-2Output channel
StartActivefalseWether the latch starts active or not
TFFfalseWether the latch is a TFF or not

addClock({ })

Function for adding clocks returns the channel that was used as an object (eg: { OutChannel1: 16 })

paramdefaultdescription
sectionID0Section to add the logic gate in
xx position of the gate
yy position of the gate
Channel-2Output channel
StartActivefalseWether the latch starts active or not
OnTime0.1Amount of time the clock is on for
OffTime0.1Amount of time the clock is off for

Path

Represents a path that a moving platform can follow, to create a ne Path use new Path(id) and then use path.addPosition({ x, y }) to add positions.

constructor

paramdefaultdescription
ID0The path id to be referenced by moving platforms

methods

addPosition({ })

takes an object containing the x and y position of the new point, points of a path are followed in order

paramdescription
xx position of the point
yy position of the point

Appendices

terminology

  • Tile: any static tile with no properties, has an id which tells the game what flavor of tile it is, and a position
  • Prefab: any entity with setable properties, (eg: buttons, enemies, triggers), these also have an id and position at bare minimum, as well as a "properties" attribute which contains all other entity specific information

channels

  • for any prefab utility function, setting the channel to -1 will have the effect of giving it no channel
  • setting the channel to -2 (default most of the time) will use the next free channel
  • all of these functions return the channels used

layers

namedescription
"T0"default layer for standard tiles
"D"default layer for dark tiles (eg: 'map dark'
"BG0"default layer for background tiles
"SS"default layer for semi-solid tiles
"H"default layer for hazard tiles
"M"default layer for map tiles (eg: 'map transparent')
1.2.10

9 months ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago