Mixin: BaseItem

Class contents

Methods list

These are special functions (or methods) that you may call on the object. these functions typically instruct the object to perform a certain operation.
    No methods

Public properties list

Properties are attributes of the object, this directly affect the object in question. Some of them can be read or written, or both.
Name Type Description
type enum returns the type as a enum
userItem.torch - The item is a torch
userItem.pistolGun - The item is a simple pistol
userItem.gravityTool - The item is a gravity gun, for moving voxels
typeAsString string returns the type as a string, such as 'torch'
pickUpState enum sets the pick-up state
itemPickUpState.once - only one player can pick up the item
' temPickUpState.always - means the item is available for everyone

Events list

Events are functions you add to your objects, that will be called by Cubiverse when certain things (events) occur.

Class Information

To instigate an Item you must spawn or place it in the world using the spawnItem() API call on the World Object.

Properties:

Name Type Description
type enum returns the type as a enum
userItem.torch - The item is a torch
userItem.pistolGun - The item is a simple pistol
userItem.gravityTool - The item is a gravity gun, for moving voxels
typeAsString string returns the type as a string, such as 'torch'
pickUpState enum sets the pick-up state
itemPickUpState.once - only one player can pick up the item
' temPickUpState.always - means the item is available for everyone

Events

onItemEquipped

Called when a player equips the item (but does not use it)

This event is trigger when the item is equipped by a player, it does not signal that they have used it (i.e. shot a gun, turned on the torch, etc.)

Parameters:
Name Type Description
playerObject object The actual playerObject who equipped the item
Example
// Print some information when a player equips an item
myItem.onItemEquipped = function( playerObject )
{
    log("I was equipped by " + playerObject.nickName) ;
}

onItemPickedUp

Called when a player picks up the item

This event is trigger on the item when any player picks up this instance of the item

Parameters:
Name Type Description
playerObject object The actual playerObject who picked it up
Example
// Print some information when a player picks up something
myItem.onItemPickedUp = function( playerObject )
{
    log("I was picked up by " + playerObject.nickName) ;
}