Hi everyone. Due to the lack of updates, AdventureCraft wiki will halt all image uploads and page edits until a recent update has been released. We thank you for your support for the past years to keep this mod alive. For now, feel free to see other maps created by previous users. ~User:System
- Login or register to hide this ad -

Script guide

From AdventureCraft

Jump to: navigation, search
Script guide
ScriptBlock.png
Type Tutorial Script
Author(s) Tyrope and CyborgDragon
Date Published May 11, 2011
Date Updated ?


Contents

Intro

This guide is written to help two groups of users.

Readers with no previous scripting or coding experience should start at The Bare Basics.

Readers with previous scripting or coding experience, start at AdventureCraft Scripting Features and use Classes and Objects for a reference.

The Bare Basics

So you're new to programming. Let me be the first to welcome you!

Once you realize how a programmer's brain work, you'll be better in JavaScript and AC's script blocks!

Logical Thinking

Normally, when people think of a thing that might happen, they say: "I'm going to say hello when the door opens."

Although this is grammatically correct, a programmer is more likely say: "If the door opens, I'm going to say hello."

This is because of how the syntax, or sentence structure, for most programming and scripting languages work.

Scripting Syntax

Hello World!

Yes, this example has been overused...but it's a good start, so why not! Many languages don't simply output whatever you type. for example, a JavaScript file containing just the words "Hello world" will blow up in your face.

To make JavaScript do something, you must put it in a 'function' or 'method'. The function for showing a message is pretty straight forward.

chat.print("Hello world!");

Let's split this into 3 parts: chat., print(); and "Hello world!"

The chat. part is the 'object' we're going to use, in this case we want to display a message in the chat window, so we use the 'chat' object.

The print(); part is the 'function', functions are parts of the script that actually do something. Most of the functions are either part of JavaScript, or created by Cryect. However, you can define your own functions, but that will come at a later part in the tutorial.

The "Hello world!" is a 'parameter' of the function, parameters are the input of a function, so the structure of this line would be:

object.function(parameter1);

Conditional Statements

Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.

In JavaScript we have the following conditional statements:

use this statement to execute some code only if a specified condition is true
use this statement to execute some code if the condition is true and another code if the condition is false
use this statement to select one of many blocks of code to be executed
use this statement to select one of many blocks of code to be executed

if

Here, we will go back to the logical thinking bit. Now, let's say you want to show a message when the player dies. You would probably say, "Say 'Game Over!' when the player dies." But a programmer would say, "If player is not alive, say 'Game Over!'"

if (!player.isAlive())
{
    chat.print("Game Over!");
}

Let's split this up as well. if() {}, !, player., isAlive(), and chat.print("Game Over!");

The if() {} part is the if statement. Inside the parentheses is your condition, and inside the brackets is what it will do if the conditions are true.

The ! is the not symbol. If the player is not alive.

The player. part is the object. It represents the player.

The isAlive() is the function. It says 'true' if the object running it is alive. "If the player is not alive," becomes "If not true."

The chat.print("Game Over!"); is the parameter. The parameters run when the condition is true.

The structure of an if statement is:

if (condition)
{
    parameter1;
    parameter2;
    parameter3;
    etc;
}

if...else

Now, let's say you still want to show a message when the player dies, however you also want something done if the player is still alive.

if (!player.isAlive())
{
    chat.print("Game Over!");
} else {
    //Player is still alive
}


if...else if...else

This builds on what is learned in the previous

if (var == 0)
{
    chat.print("var = 0!");
} else if (var == 1) {
    chat.print("var = 1!"):
} else { 
    chat.print("var = ?!");
}

switch

Alternative to if...else if...else

switch(var)
{
case 0: 
    chat.print("var = 0!");
    break;
case 1: 
    chat.print("var = 1!"):
    break;
default: 
    chat.print("var = ?!");
    break;
}

AdventureCraft Scripting Features

Music Scripts

Using the musicScripts.txt file in your map's folder, you can assign scripts to certain patterns of notes. An example would be:

555, driveMad.js, Song of Madness

Notes can be played using 0-9 on the keyboard. So, the above example would run the script called driveMad.js when the player plays 5 three times. Sharps are played using shift+number. 2, 6, and 9 do not have sharps. To represent sharps in scripts, use shift+number. If you want the player to play 4-sharp 5 7 4-sharp 5 7, you'd use the following:

$57$57, driveMad.js, Song of Madness

Classes and Objects

Chat Object

Functions

print(String msg, Object ...args)

Prints the string msg or whatever it's passed.

Effect Object

Functions

spawnParticle(String particleType, double x, double y, double z, double arg1, double arg2, double arg3)

Spawns a particle of particleType at position x, y, z with the arguments arg1, arg2, arg3 and returns the spawned particle as a ScriptEntity.

replaceTexture(String textureToReplace, String replacement)

Attempts to replace the texture textureToReplace with the texture replacement and returns true if it is successful.

getReplaceTexture(String replacedTexture)

Returns the path to the texture that replaces replacedTexture

revertTextures()

Reverts all textures to the map defaults.

setOverlay(String overlay)

Sets the texture overlay from the overlays folder as an overlay on the screen.

getOverlay()

Returns the overlay currently used.

clearOverlay()

Removes the overlay if there is any.

setFogColor(float r, float g, float b)

Sets the fog color to r, g, b, red green blue values ranging from 0 to 1.

revertFogColor()

Reverts the fog color to its original state that changes from white to black based on the light level around the player.

setFogDensity(float start, float end)

Sets the start of the fog to start distance. Everything past the end distance is not rendered.

revertFogDensity()

Reverts the fog density to its original state that is based on the fog distance settings and auto far clip setting.

getLightRampValue(int i)

Returns the currently set light ramp value for a light value of i (0..15).

setLightRampValue(int i, float f)

Sets the light ramp value for a light value of i to f.

resetLightRampValues()

Resets all light ramp values to the defaults.

registerTextureAnimation(String animName, String texName, String animatedTex, int x, int y, int width, int height)

Animates the animName image width an animatedTex replacement at the x, y coordinates of the image width dimensions width, height and name animName.

ScriptEntity Class

Class Attributes

These attributes can be manipulated directly.
immuneToFire

A Boolean for whether this ScriptEntity is immune to fire or not.

fireLevel

The amount of time this ScriptEntity will burn, in seconds. Divided by fireResistance.

fireResistance

The divisor for fireLevel, in seconds. fireLevel divided by fireResistance is the amount of time, in seconds, this ScriptEntity will burn.

air

The amount of breath this ScriptEntity currently has, in ticks. When this runs out this ScriptEntity will start drowning.

maxAir

The amount of breath this ScriptEntity has, in ticks, when first entering the water.

stunned

The amount of time this ScriptEntity is stunned, in ticks.

collidesWithClipBlocks

A Boolean for whether this ScriptEntity can pass through clip blocks or not.

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
position

The position of this ScriptEntity, stored as a ScriptVec3.

rotation

The rotation of this ScriptEntity, stored as a ScriptVecRot.

velocity

The velocity of this ScriptEntity, stored as a ScriptVec3.

burning

A Boolean for whether this ScriptEntity is burning or not.

alive

A Boolean for whether this ScriptEntity is alive or not.

riding

A Boolean for whether this ScriptEntity is mounted on another entity or not.

sneaking

A Boolean for whether this ScritpEntity is sneaking or not.

mountedEntity

The ScriptEntity that this ScriptEntity is mounted on, returns null if it isn't mounted.

insideOfWater

A Boolean for whether this ScriptEntity is submerged in water or not.

insideOfLava

A Boolean for whether this ScriptEntity is submerged in lava or not.

entityID

An int of the entities ID, read by yourEntity.entityID .

Methods

getPosition()

Returns this ScriptEntity's position as a ScriptVec3.

setPosition(double x, double y, double z)

Sets this ScriptEntity's position.

getRotation()

Returns this ScriptEntity's rotation as a ScriptVecRot.

setRotation(float yaw, float pitch)

Sets this ScriptEntity's rotation.

getVelocity()

Returns this ScriptEntity's velocity as a ScriptVec3.

setVelocity(double x, double y, double z)

Sets this ScriptEntity's velocity.

addVelocity(double x, double y, double z)

Adds this velocity to this ScriptEntity's current velocity.

setDead()

Kills this ScriptEntity. Do not use on the player, as it only causes them to stutter. Instead set the player's health to zero.

mountEntity(ScriptEntity e)

Mount this ScriptEntity on ScriptEntity e.

isBurning()

Returns true if this ScriptEntity is burning.

isAlive()

Returns true if this ScriptEntity isn't dead.

isRiding()

Returns true if this ScriptEntity is mounted on another.

isSneaking()

Returns true if this ScriptEntity is sneaking.

getEntitiesWithinRange(double dist)

Finds all ScriptEntities within the range dist of this ScriptEntity and returns them in an array.

getMountedEntity()

Returns the ScriptEntity that this ScriptEntity is mounted on. If it isn't mounted, returns null.

isInsideOfWater()

Returns true if this ScriptEntity is submerged in water.

isInsideOfLava()

Returns true if this ScriptEntity is submerged in lava.

dropItem(Item item)

Spawns a new item entity from this ScriptEntity as if it dropped it.

getImmuneToFire()

Returns true if this ScriptEntity is immune to fire.

setImmuneToFire(boolean b)

Makes this ScriptEntity immune to fire if b is true or 1, or makes it susceptible to fire if b is false or 0.

getFireLevel()

Returns the current fireLevel of this ScriptEntity as an integer.

setFireLevel(int seconds)

Sets the fireLevel of this ScriptEntity. fireLevel divided by fireResistance is the amount of time, in seconds, that this ScriptEntity will burn.

getFireResistance()

Returns the current fireResistance of this ScriptEntity as an integer.

setFireResistance(int divisor)

Sets the fireResistance of this ScriptEntity. fireLevel divided by fireResistance is the amount of time, in seconds, that this ScriptEntity will burn.

getAir()

Returns the amount of breath this ScriptEntity has left, as an integer.

setAir(int ticks)

Sets the amount of breath this ScriptEntity has left.

getMaxAir()

Returns the amount of breath this ScriptEntity will have upon being submerged in water, as an integer.

setMaxAir(int ticks)

Sets the amount of breath this ScriptEntity will have upon being submerged in water.

getStunned()

Returns the amount of time this ScriptEntity is stunned for, as an integer.

setStunned(int ticks)

Sets the amount of time this ScriptEntity will be stunned for.

attackEntityFrom(ScriptEntity e, int i)

Makes this ScriptEntity attack ScriptEntity e. Also does i damage to this ScriptEntity.

getClassType()

Returns this ScriptEntity's class type as a string.

getCollidesWithClipBlocks()

Returns true if this ScriptEntity can't pass through clip blocks.

setCollidesWithClipBlocks(boolean b)

Sets whether this ScriptEntity can pass through clip blocks or not.

EntityLiving Subclass

Class Attributes

These attributes can be manipulated directly.
health

The health of this ScriptEntity.

maxHealth

The maximum health of this ScriptEntity.

texture

The texture this ScriptEntity uses.

hurtTime

The amount of the time, in ticks, this ScriptEntity will be invincible to all damage lower than or equal to hurtTimeResistance.

hurtTimeResistance

This ScriptEntity will be invincible to all damage equal to or less than this value when hurtTime is above 0.

heldItem

The item that will be held by this ScriptEntity. Only bipeds like skeletons, zombies, and NPCs will actually show the item.

canWallJump

Can this entity wall jump or not by jumping when colliding against a wall

timesCanJumpInAir

The number of times this entity can jump in the air

jumpsInAirLeft

The number of jumps remaining for this entity while in the air (this gets reset to timesCanJumpInAir upon landing)

moveSpeed

The speed at which the entity moves.

canLookRandomly

Determines if this entity try to look around randomly. If set to false, the entity will still look at the player if they are in the entity's FOV.

randomLookRate

How often will the entity try to look randomly (in ticks)

randomLookRateVariation

Max amount of ticks to add to the randomLookRate

randomLookVelocity

How fast will this entity look when randomly looking

randomLookNext

How many ticks before choosing a new random look velocity


Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
onLadder

A Boolean for whether this ScriptEntity is on a ladder or not.

target

The entity that is this ScriptEntity's target.

lookVec

The direction this ScriptEntity is looking, stored as a ScriptVec3.

Methods

playLivingSound()

If this ScriptEntity has a living sound(e.g. pigs snorting, skeletons rattling), play it.

spawnExplosionParticle()

Spawns 'poof' particles on this ScriptEntity as if it just spawned or just died.

heal(int i)

Adds i health to this ScriptEntity up to its max health.

isOnLadder()

Returns true if this ScriptEntity is on a ladder.

getTarget()

Returns this ScriptEntity's target as a ScriptEntity if it has one, otherwise returns null.

getLookVec()

Returns this ScriptEntity's view angle as a ScriptVec3.

getHealth()

Returns this ScriptEntity's current health, as an integer.

setHealth(int i)

Sets this ScriptEntity's current health.

getMaxHealth()

Returns this ScriptEntity's maximum health, as an integer.

setMaxHealth(int i)

Sets this ScriptEntity's maximum health.

getTexture()

Returns the texture this ScriptEntity is currently using.

setTexture(string s)

Sets the texture this ScriptEntity will use.

getHurtTime()

Returns the time, in ticks, remaining for this ScriptEntity's invincibility.

setHurtTime(int i)

Sets the time, inticks, this ScriptEntity will be invincible to i.

getHurtTimeResistance()

Returns the amount of damage this entity will resist while invincible during hurtTime.

setHurtTimeResistance(int i)

Sets the amount of damage this entity will resist while invincible during hurtTime.

getHeldItem()

Returns the Item held by this ScriptEntity.

setHeldItem(Item item)

Sets the Item held by this ScriptEntity to item.

getCanWallJump()

Returns true if this ScriptEntity can wall jump.

setCanWallJump(boolean b)

Sets whether or not this ScriptEntity can wall jump.

getTimesCanJumpInAir()

Returns with how many times ScriptEntity can jump in midair.

setTimesCanJumpInAir(int i)

Sets the number of times ScriptEntity can jump in midair.

getJumpsInAirLeft()

Returns with how many jumps are remaining for this ScriptEntity in the air (this gets reset to timesCanJumpInAir upon landing).

setJumpsInAirLeft(int i)

Sets how many jumps are remaining for this ScriptEntity in the air (this gets reset to timesCanJumpInAir upon landing).

getMoveSpeed()

Returns with the speed at which this ScriptEntity moves.

setMoveSpeed(int i)

Sets the speed at which this ScriptEntity moves.

EntityCreature Subclass

Class Attributes

These attributes can be manipulated directly.
target

The ScriptEntity that is this ScriptEntity's target.

canPathRandomly

Determines whether the entity will wander around randomly. This seems to get reset to true on loads.

fov

Sets the entity's field of view (in degrees)

Methods

setTarget(Entity e)

Sets this ScriptEntity's target to ScriptEntity e.

getTarget()

Returns this ScriptEntity's target as a ScriptEntity if it has one, otherwise returns null.

hasPath()

Returns true if this ScriptEntity has a path.

pathToEntity(Entity e)

Supposed to make this ScriptEntity move to ScriptEntity e's location, however this method currently does not function as it should.

pathToBlock(int x, int y, int z)

Supposed to make this ScriptEntity move to the position marked by x, y, z, however this method currently does not function as it should.

EntityMob Subclass

Class Attributes

These attributes can be manipulated directly.
attackStrength

The amount of damage this ScriptEntity will do.

Methods

setAttackStrength(int i)

Sets the amount of damage this ScriptEntity will do to i.

getAttackStrength

Returns the amount of damage this ScriptEntity will do.

Arrow Subclass

Class Attributes

These attributes can be manipulated directly.
These are assumed and should be tested, Using Methods would be best.
inBlockID

An int of the ID of the block which the arrow is stuck in.

inBlockCoords

A ScriptVec3 of the position of the block the arrow is stuck in.

isPlayersArrow

A Boolean of whether or not the player can pick up the arrow.

getOwner

A ScriptEntity to which spawned this arrow.

Methods

getInBlockID()

Returns the ID of the block the arrow is stuck in.

getInBlockCoords()

Returns a ScriptVec3 of the position of the block the arrow is stuck in.

getIsPlayersArrow()

Returns whether or not the player can pick up the arrow.

setIsPlayersArrow(boolean b)

Sets whether or not the player can pick up the arrow.

getOwner()

Returns the ScriptEntity which spawned this arrow.


Player Object

Attributes

cloak This is the string used for the player's cloak. If there is none, this is null.

Methods

getInventory()

Returns the player's inventory as an Inventory object. This is not a 'static snapshot,' you only need to set one variable to this and it will be updated as the player's inventory changes.

swingMainHand()

Swings the item in the player's right hand.

swingOffHand()

Swings the item in the player's left hand.

getCloak()

Returns the path to the texture currently used for the cloak.

setCloak(string texture)

Sets the cloak to texture

Inventory Class

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
sizeInventory

The size of this Inventory, an integer that is not zero-based.

name

The name of the Inventory. The player's inventory is called 'Inventory', whether this is true for others has yet to be tested.

stackLimit

The maximum quantity of any stack of Items for this Inventory.

Methods

getSizeInventory()

Returns the size of this Inventory, as an integer that is not zero-based.

getName()

Returns the name of this Inventory, as a string.

getStackLimit()

Returns the maximum quantity Items in this Inventory can stack to.

getItemInSlot(int slot)

Returns the Item in slot, if there is no Item, it returns null.

decrementItem(int slot, int amount)

Returns the Item in slot after decrementing its quantity by amount. If there is no Item, it returns null.

setSlot(int slot, Item item)

Puts the Item item into slot.

emptySlot(int slot)

Removes the Item in slot if there is one.

PlayerInventory Subclass

Class Attributes

cursorItem

The Item that is held by the player's cursor. Is null if there is nothing.

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
armorValue

The quantitative value assigned to armor. Full leather armor is five, full diamond is twenty.

currentItem

The Item that is in the player's right hand. Is null if there is nothing.

offhandItem

The Item that is in the player's left hand. Is null if there is nothing.

Methods

getSlotContainingItem(int itemID)

Returns the slot that contains an Item with an ID of itemID. Returns -1 if no matching item is found.

getSlotContainingItemDamage(int itemID, int damage)

Returns the slot that contains an Item with an ID of itemID and a damage value of damage. Returns -1 if no matching item is found.

setCurrentItem(int itemID)

Switches the current item to an Item with the ID itemID, if there is one on the quick bar.

changeCurrentItem(int i)

Switches the current item to the left if i is a positive value. Conversely, switches it to the right if i is a negative value.

consumeItem(int itemID)

Attempts to consume a single unit of an Item with the ID itemID. Returns true if it succeeds.

consumeItemAmount(int itemID, int damage, int amount)

Attempts to consume amount of an Item with the ID itemID and damage value damage. Returns true if it succeeds.

getArmorValue()

Returns the quantitative value assigned to armor, as an integer.

dropAllItems()

Makes the player's items spill everywhere as if he died.

getCurrentItem()

Returns the Item that is in the player's right hand. Returns null if there is nothing.

getOffhandItem()

Returns the Item that is in the player's left hand. Returns null if there is nothing.

swapOffhandWithMain()

Swaps the left and right hand.

addItem(Item item)

Attempts to add Item item to the player's inventory and returns true if it succeeds.

getCursorItem()

Returns the Item that is held by the player's cursor. Returns null if there is nothing.

setCursorItem(Item item)

Sets the Item that is held by the player's cursor to item.

Item Class

Class Attributes

These attributes can be manipulated directly.
itemID

The ID of this Item.

quantity

The quantity of this Item.

damage

The damage value of this Item.

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
maxDamage

The maximum damage this Item will take before breaking.

Methods

getItemID()

Returns the ID of this Item, as an integer.

setItemID(int itemID)

Sets the ID of this Item.

getQuantity()

Returns the quantity of this Item, as an integer.

setQuantity(int i)

Sets the quantity of this Item.

getDamage()

Returns the damage value of this Item, as an integer.

setDamage(int i)

Sets the damage value of this Item.

getMaxDamage()

Returns the maximum damage this Item can sustain, as an integer.

copy()

Returns a copy of this Item that is not bound to a inventory. If you don't use this or one of the constructors to make a new Item object, any changes you make to an Item will affect the Item directly in the inventory.

Constructors

Item(int itemID)

Creates a new Item object with the ID itemID, no damage value, and only one in quantity.

Item(int itemID, int quantity)

Creates a new Item object with the ID itemID and a quantity of quantity, with no damage value.

Item(int itemID, int quantity, int damage)

Creates a new Item object with the ID itemID, a quantity of quantity, and a damage value of damage The damage value could also be used as the ID value of an item (for example Dyes: Item(351,1,5) = Purple Dye).

ScriptVec3 Class

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
x

The x value of the vector.

y

The y value of the vector.

z

The z value of the vector.

Methods

add(ScriptVec3 other)

Adds other to this vector

subtract(ScriptVec3 other)

Subtracts other from this vector

length()

Returns the length of this vector

distance(ScriptVec3 other)

Returns the distance between the endpoints of the two vectors

scale(double s)

Multiplies the length of the vector by s

ScriptVecRot Class

Read-Only Class Attributes

These attributes cannot be manipulated directly, only read.
yaw

The yaw of this rotation vector.

pitch

The pitch of this rotation vector.

Sound Object

Functions

playSoundUI(string soundName)

Plays a normal 2d sound

playSoundUI(string soundName, int volume, int pitch)

Plays a 2d sound with a set volume and pitch change

playSound3D(string soundName, int x, int y, int z)

Plays a sound at the specified 3d position

playSound3D(string soundName, int x, int y, int z, int volume, int pitch)

Plays a sound at the specified 3d position, volume, and pitch change.

playMusic(string musicName)

Plays the specified music

playMusic(string musicName, int fadeOut, int fadeIn)

Plays the specified music, with fading out the current playing music over x ms and fades in the new music over y ms.

stopMusic()

Stops the current music

Time Object

Attributes

These attributes can be manipulated directly.
time

The currrent time. 6000 is noon, 18000 midnight, 24000 and 0 dawn, and 12000 dusk.

rate

The rate at which time progresses. 1 means a day lasts twenty minutes. 2 means ten minutes, etc.

Read-Only Attributes

These attributes cannot be manipulated directly, only read.
tickCount

The number of ticks that have happened during throughout the map. This is stored for each save and will keep counting up as the player plays.

Functions

get()

Returns the current time, as a float.

set(long time)

Sets the current time. 6000 is noon, 18000 midnight, 24000 and 0 dawn, and 12000 dusk.

getTime()

Returns the current time, as a float.

setTime(long time)

Sets the current time. 6000 is noon, 18000 midnight, 24000 and 0 dawn, and 12000 dusk.

getRate()

Returns the current rate at which time progresses, as a float.

setRate(float rate)

Sets the rate at which time progresses.

getTickCount()

Returns the current number of ticks for this save, as a long.

sleep(float seconds)

Used to make scripts pause for seconds seconds. The minimum is 0.5 seconds.

UI Class

Class Attributes

x

The current position of the UI element along the x axis of the screen. 0 is the very left edge.

y

The current position of the UI element along the y axis of the screen. 0 is the very top edge.

Methods

addToScreen()

Adds a UI element back to the screen at the top if it's been removed.

removeFromScreen()

Removes a UI element from the screen.

pushToFront()

Moves a UI element to the front of the screen, displaying on top of everything else.

pushToBack()

Moves a UI element to the back of the screen, displaying behind everything else.

Read-Only Attributes

height

The height of the user's screen.

width

The width of the user's screen.

Functions

getHeight()

Returns the height of the user's screen.

getWidth()

Returns the width of the user's screen.

getStringWidth(String s)

Returns the width String s would be when displayed on the screen.

UIContainer Subclass

Methods

add(UIElement)

Adds the UIElement to this UIContainer. The UIElement's x, y position are now offsets from this UIContainer's position.

addToBack(UIElement)

Adds the UIElement to this UIContainer at the back, making it render first, and thus everything else in this UIContainer render after and on top of it. The UIElement's x, y position are now offsets from this from this UIContainer's position.

remove(UIElement)

Stops UIElement from rendering.

clear()

Removes all UIElements from this container and stops them from rendering.

Constructors

UIContainer(int x, int y)

Creates a new UIContainer object at position x, y.

UILabel Subclass

Class Attributes

text

The current text shown by the UILabel.

red

How red the text is, ranging from 0 to 1.

green

How green the text is, ranging from 0 to 1.

blue

How blue the text is, ranging from 0 to 1.

alpha

How transparent the text is, ranging from 0 (opaque) to 1(invisible).

shadow

A boolean for whether or not the text has a shadow.

centered

A boolean, if this is set, the text will be centered about (x) instead of having its left side there

Constructors

UILabel(string text, int x, int y)

Creates a new UILabel object with the text text at position x, y. It is best to assign it to a variable so that you can manipulate it further.

UIRect Subclass

Class Attributes

width

The width of the UIRect.

height

The height of the UIRect.

red

How red the UIRect is, ranging from 0 to 1.

green

How green the UIRect is, ranging from 0 to 1.

blue

How blue the UIRect is, ranging from 0 to 1.

alpha

How transparent the UIRect is, ranging from 0 (transparent) to 1 (opaque).

Constructors

UIRect(int x, int y, int width, int height, float red, float green, float blue, float alpha)

Creates a new UIRect object at position x, y with the width and height of width, height, and with the RGBA values red, green, blue, alpha.

UISprite Subclass

Class Attributes

texture

Sets this UISprite's current texture.

width

The width of the UISprite.

height

The height of the UISprite

u

The starting x position in the texture.

v

The starting y position in the texture.

red

How much red of the texture to show, ranging from 0 to 1.

green

How much green of the texture to show, ranging from 0 to 1.

blue

How much blue of the texture to show, ranging from 0 to 1.

alpha

How transparent the UISprite is, ranging from 0 (opaque) to 1(invisible).

Constructors

UISprite(string texture, int x, int y, int width, int height, int u, int v)

Creates a new UISprite object using the texture texture at position x, y with the width and height of width, height, and starting the u, v position in the texture.

World Object

Functions

getBlockID(int x, int y, int z)

Returns the ID of the block at x, y, z, as an integer.

setBlockID(int x, int y, int z, int id)

Sets the ID of the block at x, y, z to id.

getMetadata(x, y, z)

Returns the metadata of the block at x, y, z, as an integer.

setMetadata(int x, int y, int z, int metadata)

Sets the metadata of the block at x, y, z to metadata.

setBlockIDAndMetadata(int x, int y, int z, int id, int metadata)

Sets the ID and metadata of the block at x, y, z to id and metadata, respectively.

getLightValue(int blockX, int blockY, int blockZ)

Returns the current light value of the specified block.

triggerBlock(int blockX, int blockY, int blockZ)

Quick trigger on and off for the specified block coords

triggerArea(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)

Quick trigger on and off for the specified area.

setTriggerArea(int blockX, int blockY, int blockZ, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)

Enables an active trigger for the specified area from a specified block. Trigger area will remain active till its removed.

setTriggerArea(int blockX, int blockY, int blockZ, int areaID, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)

Enables an active trigger for the specified area from a specified block with a specified areaID. Trigger area will remain active till its removed.

removeTriggerArea(int blockX, int blockY, int blockZ, int areaID)

Removes a trigger for a specified block coord and areaID.

removeTriggerAreas(int blockX, int blockY, int blockZ)

Removes all triggers for a specified block coord.

spawnEntity(string entityType, int x, int y, int z)

Spawns and then returns an Entity of EntityType at given location.

Weather Object

These attributes can be manipulated directly.

Attributes

precipitating

A boolean for whether it's raining/snowing or not.

temperatureOffset

The offset of the biome temperatures across the world. If this is 1 and it's precipitating, it'll rain everywhere, even in places that would otherwise be snowy. Vice versa, if this is -1 and it's precipitating, it'll snow everywhere.

thundering

A boolean for whether it's thundering or not.

Functions

setPrecipitating(boolean precipate)

Sets whether it's raining/snowing or not.

getPrecipitating()

Returns true if it's raining/snowing.

setTemperatureOffset(double tempOffset)

Sets the temperature offset for the world.

getTemperatureOffset()

Returns the temperature offset for the world.

setThundering(boolean thunder)

Sets whether it's thundering or not.

getThundering()

Returns true if it's thundering.

Script Object

runScript(fileName)

Runs a .js script from the scripts folder.
Returns the last evaluated object (or function), like progn in common lisp
Note: The other script can't use the time.sleep command, but if you want to do so, then create a function in another file on loading and use the time.sleep command within the function.

openUrl(String url)

Asks the player to open the specified url.

openUrl(String url, String msg)

Asks the player the specified message to open the chosen url.

Keyboard Object

Attributes

These attributes can be manipulated directly.

keyID

has the key pressed and

keyState

has whether the key was pressed down/up
If the last line returns false then it will be as if the player didn't press that key

keyForwardScript

Script to run when pressing forward

keyBackScript

Script to run when pressing back

keyLeftScript

Script to run when pressing left

keyRightScript

Script to run when pressing right

keyJumpScript

Script to run when pressing jump

keySneakScript

Script to run when pressing sneak

Functions

bindKey(int keyID, string scriptName)

Executes the specified script whenever the specified key is pressed.

unbindKey(int keyID)

Removes the script bound to the specified keyID.

bindAllKeyScript(string scriptName)

Whenever any key is pressed, the specified script is run. The variable keyID contains the ID of the key pressed.

unbindAllKeyScript()

Removes the binding to the script for all key presses.

isKeyDown(int keyID)

Returns if the specified key is down.

getKeyName(int keyID)

Returns the name of the specified keyID.

getKeyID(String keyName)

Returns the ID of the specified key name.

Model Class

Attributes

These attributes can be manipulated directly.
texture

A string for the current texture used by the model

attachedTo

The entity this model is attached to

modelAttachment

The model this model is attached to

Functions

addBox(String boxName, float offsetX, float offsetY, float offsetZ, int width, int height, int depth, int u, int v)

Creates a box (at the location specified by offset from the model's origin) of size width by height by depth, using the last texture set starting at point (u,v)

addBoxExpanded(String boxName, float offsetX, float offsetY, float offsetZ, int width, int height, int depth, int u, int v, float expand)

Creates a box (at the location specified by offset from the model's origin) of size width by height by depth, using the last texture set starting at point (u,v) and then expands it by specified value (stretching the texture)

setPosition(double newX, double newY, double newZ)

Sets the previous position as well so it won't lerp between the old and new

moveTo(double newX, double newY, double newZ)

Sets just the current position so it will lerp over a tick

moveBy(double moveX, double moveY, double moveZ)

Moves the model taking into account the rotation.

setRotation(float newYaw, float newPitch, float newRoll)

Sets the Yaw, Pitch and Roll of the model.

rotateTo(float newYaw, float newPitch, float newRoll)

Rotates the Yaw, Pitch and Roll to specified values.

rotateBy(float rYaw, float rPitch, float rRoll)

Adds specified values to Yaw, Pitch and Roll.

removeFromRendering()

Stops the model from rendering

addToRendering()

Adds the model for rendering

Constructors

Model()

Creates a model with a texture size of 64x32, stretching the texture to that size.

Model(int width, int height)

Creates a model with a texture size specified by the arguments, stretching the texture to that size.

External JS Resource

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox