My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
LuaScripting  

Camera.SetYaw(float Degrees)

Sets the yaw for the camera. Degrees is from 0 to 360.

-- Set camera to 90 degrees so it faces the right
Camera.SetYaw(90)

Camera.SetPitch(float Degrees)

Sets the pitch for the camera. Degrees is from -89 to 89.

-- Set camera to 35 degrees so it faces downwards
Camera.SetPitch(35)

pointer Object.GetPointer(string ObjectName)

Gets a pointer to an object.

-- Get player pointer
Player = Object.GetPointer("player")

Object.GetName(pointer Object)

Returns the name of an object given a pointer.

-- Get object name
ObjectName = Object.GetName(Object)

Object.SetPosition(pointer Object, float X, float Y, float Z)

Sets the position of an object.

-- Set position of the player
Object.SetPosition(Player, 0, 5, 2)

vector3 Object.GetPosition(pointer Object)

Gets the position of an object.

-- Get position of the player
X, Y, Z = Object.GetPosition(Player)

Object.SetAngularVelocity(pointer Object, float VelocityX, float VelocityY, float VelocityZ)

Sets the angular velocity of an object.

-- Set the cylinder to rotate about the z axis
Object.SetAngularVelocity(Cylinder, 0, 0, 2)

Object.Stop(pointer Object)

Stops the linear and angular motion of an object.

-- Stop the player from moving
Object.Stop(Player)

Object.SetLifetime(pointer Object, float Seconds)

Stops the lifetime of an object in seconds. After the elapsed time, the object is deleted.

-- Delete the object in 5 seconds
Object.SetLifetime(Object, 5)

Object.Delete(pointer Object)

Deletes an object.

-- Delete the object
Object.Delete(Object)

Orb.Deactivate(pointer OrbObject, string OnDeactivateFunction, float DeactivateTime)

Deactivates an orb. DeactivateTime is specified in seconds, and calls OnDeactivateFunction after that time.

-- Collision callback for an orb
function OnHitOrb(MainObject, OtherObject)
	if OtherObject == Player then
		Orb.Deactivate(MainObject, "OnOrbDeactivate", 2)
	end
end

Timer.DelayedFunction(string Function, float Time)

After Time seconds, Function is called.

-- Call a function after 20 seconds
Timer.DelayedFunction("ShowMoreText", 20)

float Timer.Stamp()

Returns the number of seconds since the level was started.

-- Get a timestamp
Seconds = Timer.Stamp()

Level.Win()

Wins the level.

-- Called when an orb is deactivated
function OnOrbDeactivate()
	GoalCount = GoalCount - 1
	if GoalCount == 0 then
		Level.Win()
	end
end

pointer Level.GetTemplate(string TemplateName)

Returns a pointer to a template.

-- Get the crate template from the xml file
CrateTemplate = Level.GetTemplate("crate")

pointer Level.CreateObject(string ObjectName, pointer Template, float PositionX, float PositionY, float PositionZ, float RotationX, float RotationY, float RotationZ)

Creates an object from a template. RotationX, RotationY, RotationZ are optional.

-- Create a new object at Y=5
NewObject = Level.CreateObject("crate", CrateTemplate, 0, 5, 0)

GUI.TutorialText(string Text, float Time)

Displays tutorial text on the screen for Time seconds. Use \n for a new line.

-- Display some text
GUI.TutorialText("Press [" .. KEY_FORWARD .. "] to move forward.\nUse the mouse to look around.", 15)

Random.Seed(int Seed)

Sets the seed for the random number generator.

-- Set seed
Random.Seed(50)

float Random.GetFloat(float Min, float Max)

Returns a random float between Min and Max

-- Get a random number from 0.5 to 2.5
X = Random.GetFloat(0.5, 2.5)

int Random.GetInt(int Min, int Max)

Returns a random integer between Min and Max

-- Get a random number from 10 to 20
Time = Random.GetInt(10, 20)

Sign in to add a comment
Powered by Google Project Hosting