Return to Index

mcontroller

Description:

The mcontroler contains all the movement values of a the player. you will be able to find the coordinates of a player, the velocity at which it goes and may other indicators such as if the player is in water, on the ground or jumping.







Contains




Documentation

canJump() : bool

Description:

This function is used to determine if the player can jump.

Parameter(s):

No Parameter(s)

Retun:

bool :

A variable indicating if the player can jump.

True if the player can jump.
False if the player cannot jump.

Example:

if mcontroller.canJump() then
    world.logInfo("If you jump you will jump, not fly.");
end

position() : table<float>

Description:

This function can be used to check the player's coordinate in the world he is inside of.

Parameter(s):

No Parameter(s)

Retun:

table<float>:

A table containing the player's coordinate, the first one is x and the second one is y.

If you only want the x or y coordinate you may use the functions xPosition() or yPosition() instead.

Note: The coordinates cannot be negative.

Position Table
positionvalue
1posX
2posY

Examples:

local pos = mcontroller.position();
local posX = pos[1];
local posY = pos[2];

mcontroller.position()[1] == mcontroller.xPosition() = true

mcontroller.position()[2] == mcontroller.yPosition() = true

running() : bool

Description:

This function is used to determine whether or not the player is running.

Parameter(s):

No Parameter(s)

Retun:

bool :

A variable indicating the player's running state.

True if the player is running.
False if the player isn't running.

Example:

if mcontroller.running() then
    world.logInfo("Please, don't run around pools");
end

velocity() : table<float>

Description:

This function is used to determine the velocity of the player on both axis.
You can only request a sigle axis by using xVelocity() or yVelocity().

Parameter(s):

No Parameter(s)

Retun:

table<float> :

A table containing the velocity of the player on both axis.

Velocity Table
positionvalue
1velX
2velY

Example:

local vel = mcontroller.velocity();
local velX = vel[1];
local velY = vel[2];

mcontroller.velocity()[1] == mcontroller.xVelocity() = true

mcontroller.velocity()[2] == mcontroller.yVelocity() = true

running() : bool

Description:

This function is used to determine whether or not the player is walking.

Parameter(s):

No Parameter(s)

Retun:

bool :

A variable indicating the player's walking state.

True if the player is walking.
False if the player isn't walking.

Example:

if mcontroller.walking() then
    world.logInfo("if you're on a moon, your moonwalking!");
end

xPosition() : float

Description:

This function is used to determine the x coordinate of the player in the world it currently stands in.
You can only request both axis by using the position() function.

Parameter(s):

No Parameter(s)

Retun:

float :

A float variable containing the x coordinate of the player.

Note: It cannot be negative.

Example:

if mcontroller.xPosition() == 0 then
    world.logInfo("Wow you are at the middle of the planet. This is almost impossible.");
end

mcontroller.xPosition() == mcontroller.position()[1] = true

xVelocity() : float

Description:

This function is used to determine the horizontal velocity of the player.
You can only request both axis by using the velocity() function.

Parameter(s):

No Parameter(s)

Retun:

float :

A float variable containing the horisontal velocity of the player.

Note: It cannot be negative.

Example:

if mcontroller.xVelocity() >= 88 then
    world.logInfo("You might break the speed limit!");
end

mcontroller.xVelocity() == mcontroller.velocity()[1] = true

yPosition() : float

Description:

This function is used to determine the y coordinate of the player in the world it currently stands in.
You can only request both axis by using the position() function.

Parameter(s):

No Parameter(s)

Retun:

float :

A float variable containing the y coordinate of the player.

Note: It cannot be negative.

Example:

if mcontroller.yPosition() == 0 then
    world.logInfo("well, you reach the rock bottom of this planet! Have a cookie!");
    world.spawnItem("cake", mcontroller.position(), 1, { shortdescription = "Cookie", description = "HAHAHA there never was any cookie!"});
end

mcontroller.yPosition() == mcontroller.position()[2] = true