Class: GunItem

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

Events list

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

Class Information

Constructor

new GunItem()

This API references is used to document the common (base) functionality that all guns have, if a gun has additional API calls there will be a dedicated section for it - otherwise assume it supports only the functionality mentioned here.
Important:
  • You cannot spawn a gun object directly, you must instead pick a type of gun to spawn (such as piston, gravity, etc.) using the World.spawnItem() or similar API call.

Extends

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
Inherited From:
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
Inherited From:
Example
// Print some information when a player picks up something
myItem.onItemPickedUp = function( playerObject )
{
    log("I was picked up by " + playerObject.nickName) ;
}