Environments
Environments are an important aspect of PPL and Hybroid Live. Not specifying the environment will result in a transpile-time error.
The environment definition must be the first statement in the file.
env MyLevel as Level
// The rest of the code
The environment definition follows a special syntax:
env EnvName as EnvType│ │ └─ Environment type│ └─ Environment name└─ Environment keyword
The following environment types are available:
Level
- for working with levels- The
Pewpew
andFmath
libraries are available
- The
Mesh
,Sound
- for working with meshes and sounds respectivelyFmath
andPewpew
libraries are not allowed.Math
library is allowed
Shared
- for helpers being used by multiple environments with different environment types- The
Pewpew
library is not allowed
- The
The Table
and String
libraries are allowed everywhere.
Using environments from other files
Section titled “Using environments from other files”Consider this example:
env MyHelper as Shared
fn Greet(name) { Print("Hello" .. name .. "!")}
You can import the Greet
function by prepending the environment before the function name:
env MyLevel as Level
MyHelper:Greet("Peter") // -> Hello, Peter!
If you don’t want to prepend the environment every time, you can use use
statement instead:
env MyLevel as Leveluse MyHelper
Greet("Peter") // -> Hello, Peter!
Using mesh environments for entities
Section titled “Using mesh environments for entities”env MyMesh as Mesh
pub meshes = [ struct{ vertexes = list<list<number>>[], segments = list<list<number>>[], colors = list<number>[] }]
env MyLevel as Level
let myEntity = Pewpew:NewEntity(0f, 0f)Pewpew:SetEntityMesh(myEntity, MyMesh, 0)
Using sound environments
Section titled “Using sound environments”env MySound as Sound
pub sounds = [ ParseSound("https://pewpew.live/jfxr/index.html#...")]
env MyLevel as Level
Pewpew:SetLevelSize(500f, 500f)Pewpew:PlaySound(MySound, 0, 100f, 100f)