Section (class)

From PGE Wiki
Revision as of 23:28, 1 June 2020 by Novarender (talk | contribs) (Added Section.origBoundary)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This class provides fields/functions for managing Sections in the current level.

Static functions

Static Section Functions (level only)
Function Return values Description
Section.get() table of Section Returns the array of Sections. The first element of the array represents the first section. (LunaLua ≥ v0.7.2)
Section.get(number sectionID) Section Gets the section object by the section id. Valid number are from 1 (first section) to 21 (last section) (LunaLua ≥ v0.7.2)
Section(number index) Section Returns the Section object by the section id. Valid numbers are from 0 (first section) to 20 (last section)

Instance functions

These fields and functions are part of Section Objects and have to be called for that object. Trying to call them from the static Section 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,mySection in ipairs(Section.get()) do
        mySection.backgroundID = index
    end
end
Section class
Type Function/Field Return values/Value type Description
Field Section.boundary RECTd The section boundary.
Field Section.origBoundary RECTd The original section boundary. If you change the section boundary via Section.boundary, this will store the original boundary.
Field Section.musicID number The ID of the section's music. (LunaLua ≥ v0.7.2)
Field Section.backgroundID number The ID of the section's background. (LunaLua ≥ v0.7.2)
Field Section.isLevelWarp boolean True if the section is a warp level. (LunaLua ≥ v0.7.2)
Field Section.hasOffscreenExit boolean True if this section has an offscreen exit (the level can be exited by going offscreen in this section). (LunaLua ≥ v0.7.2)
Field Section.noTurnBack boolean True if section has one-way scrolling (the screen cannot scroll to the left, only to the right). (LunaLua ≥ v0.7.2)
Field Section.isUnderwater boolean True if the section is an underwater section. (LunaLua ≥ v0.7.2)
Field Section.wrapH boolean True if section has horizontal wrap enabled. (LunaLua ≥ v0.7.2)
Field Section.wrapV boolean True if section has vertical wrap enabled. (LunaLua ≥ v0.7.2)