Musicbox (class)

From PGE Wiki
Jump to: navigation, search

This class provides fields/functions for managing musicboxes on the overworld.

Static functions

Static Path Functions
Function Return values Description
Musicbox.count() number How many musicboxes are on the overworld.
Musicbox.get() table of Musicbox Returns all musicboxes on the overworld.
Musicbox.get(number or table ids) table of Musicbox Returns all musicboxes with the matching item ids.
Musicbox.getIntersecting(number x1, number y1, number x2, number y2) table of Musicbox Returns all musicboxes which are intersecting with an area from x1/y1 to x2/y2.

Instance functions

These fields and functions are part of Musicbox Objects and have to be called for that object. Trying to call them from the static Musicbox class will result in an error. Example (feel free to copy it into your lua file to see how it works):

function onStart()
    for index,myBox in ipairs(Musicbox.get()) do
        myBox.id = 1
    end
end
Path class
Type Function/Field Return values/Value type Description
Field Musicbox.id double The id of the musicbox.
Field Musicbox.x double The x position of the musicbox.
Field Musicbox.y double The y position of the musicbox.
Field Musicbox.width double The width of the musicbox.
Field Musicbox.height double The height of the musicbox.
Field Musicbox.isValid boolean Whether the object is valid or not.