Skip to content

Level API Documentation

DetectiveSmith edited this page Apr 6, 2015 · 12 revisions

Level.getTexture( number Dimension, number X, number Y )

Return Value: number BackgroundColor, number ForegroundColor, number TextCharacter

Returns the top-most (currently visible) texture there is based on the given coordinates.

Level.setInGame( boolean )

Sets whether or not the user is in game.

Level.isInGame()

Return Value: boolean

Returns true if the user is currently in game. false otherwise.

Level.setSingleplayer( boolean )

Sets whether or not the game is in single player mode.

Level.isSingleplayer()

Return Value: boolean

Returns true if the user is playing in singleplayer. false otherwise.

Level.getLightingMap()

Return Value: table lightingMap

Returns the lighting map, used to tell the game where there is and isn't light.

Level.setTime( number Time )

Takes a number to set as the time in game. Can be any number between 0 and 24.

Level.getTime()

Return Value: number Time

Level.setWorld( table World )

Sets the world for other API's to refer to when functioning.

Level.getWorld()

Return Value: table currentWorld

Returns the current world being used by other APIs.

Level.getSize()

Return Value: number worldWidth, number worldHeight

Returns the width and height of the world.

Level.setSpawnPoint( table newSpawn )

Sets the spawn point of the world where players will respawn at. _newSpawn _ should be in the format '{x, y}'.

Level.getSpawnPoint()

Return Value: table spawnPoint

Returns a table value of the current spawnPoint in the format '{x, y}'.

Level.updateArea( number Dimension, number StartX, number StartY, number EndX, number EndY )

Updates the specified area of the world by making liquids flow, grass grow, scripts run, etc.

Level.convertID( number or string ID )

Return Value: number or string ID

Takes an ID and converts it into it's string equivalent.

'Level.convertID(1)' Returns "Stone"

'Level.convertID("Stone")' Returns 1

Level.checkForCollision( number Dimension, number X, number Y )

Return Value: Boolean

Checks if there is a block obstructing a player or entity from going over given coordinates.

Level.setData( number Dimension, number X, number Y, table newData )

Sets the world data for the given point. newData is a table structured like this: local exampleData = { Block = {ID = Number or False}, Tile = {ID = Number or False} }

You can give both a Tile and Block to reassign, or just one. Level.setData(0, 10, 10, {Block = {ID = 1}}) This sets the block at 10, 10 in dimension 0 to 1, or stone.

Level.getData( number Dimension, number X, number Y )

Return Value: table { Block = {ID = Number or False}, Tile = {ID = Number or False} }

Returns the data of the world from the specified coordinates and dimension.

Level.setOffset( number X, number Y )

Sets the camera offset, affecting what part of the world the player will be seeing.

Level.getOffset()

Return Value: number OffsetX, number OffsetY

Returns the current offset of the camera.

Level.generateWorld( table WorldBase )

Return Value: table World

Generates a new world, just like the ones used in the game. It uses a premade world created by the function Level.newWorld()

Level.newWorld( number Length, number Width )

Return Value: table WorldBase

Using this function will create a table for the function level.generateWorld() to use later.

Returns the current in game time.

Undocumented Functions ( + Reasons )

Level.chance(blockTable, totalPercent)

This function is widely used in my world generation algorithum. However, it doesn't work at ALL how it should, and isn't recommended to be used.

Level.checkForIDs(number findID, boolean topLayer, number startX, number startY, number endX, number endY)

This function hasn't been completed yet.

Level.replaceIDs(number originalID, number newID, boolean topLayer, number startX, number startY, number endX, number endY)

This function hasn't been completed yet.

Level.worldBase( number Length, number Width )

This needs a reason.


Clone this wiki locally