-
Notifications
You must be signed in to change notification settings - Fork 6
Functions
To interact with the game, use methods in a module named Besiege.
-
void Log(string msg)
Used to print into console.Besiege.Log("Hello World")
You can also use the
printkeyword.print "Hello World"
-
float GetTime()
Returns time from the start of the simulation. Consistent with the in-game timescale slider.t = Besiege.GetTime()
-
bool Exists(string blockId)
Used to check if the block exists is present in a physical form. ReturnsFalsefor nonexisting, destroyed or intangible blocks.if not Besiege.Exists("BOMB 1"): print "Bomb has exploded."
-
Block GetBlock(string blockId)
Returns the block handler for the block. With it, you can manipulate Besiege blocks. Read more on the Block handlers page.
Instead of logging your debugging information to console, you can use the Watchlist.
-
void Watch(string name)
Adds a global variable to the watchlist.x = 3 Besiege.Watch("x")
-
void Watch(string name, object value)
Reports the value to the watchlist under the specified display name.Besiege.Watch("Rocket velocity:", rocket.Velocity)
-
void ClearWatchlist()
Clears all entries from watchlist.
-
float MachineMass
Returns the mass of the machine. -
UnityEngine.Vector3 MachineCenterOfMass
Returns the world center of mass of the machine as a vector.
You can raycast your mouse pointer or a custom ray using the following functions.
-
UnityEngine.Vector3 GetRaycastHit()
Returns the point where mouse cursor is pointing in a form of a vector. -
UnityEngine.Vector3 GetRaycastHit(Vector3 origin, Vector3 direction)
Returns the point where a ray, defined by origin and direction vectors is pointing in a form of a vector. -
TrackedCollider GetRaycastCollider()
Returns a TrackedCollider object, hit by the mouse pointer raycast. -
TrackedCollider GetRaycastCollider(Vector3 origin, Vector3 direction)
Returns a TrackedCollider object, containing information about the hit collider. Useful for tracking moving objects.tc = Besiege.GetRaycastCollider()
-
UnityEngine.Vector3 TrackedCollider.Position
Returns tracked collider's position. If it no longer exists, it returns it's last known position. -
bool TrackedCollider.IsBlock
Does the collider represent a block. If so, you can retrieve it's reference withBlockproperty. -
Block TrackedCollider.Block
Block handler object, represented by this collider. -
string TrackedCollider.Name
Name of the game object for identifying what's been hit.
Example using GetRaycastCollider() function to get laser hit location. If it hits a WaterCannon, it shoots it. View it in action
laser = Besiege.GetBlock("LASER 1") def Update(): origin = laser.Position + laser.Forward direction = laser.Forward try: collider = Besiege.GetRaycastCollider(origin, direction) if collider.Name == "WaterCannon": collider.Block.Shoot() except Exception as e: # If raycast doesn't hit anything, it throws an exception. print e
-
With the following functions, you can easily put a mark (small coloured sphere object) to a desired location, to help you visualise and debug your scripts.
-
Mark CreateMark(UnityEngine.Vector3 pos)
Initializes and returns a Mark game object at the given position.mousepointer_location = Besiege.GetRaycastHit() mark = Besiege.CreateMark(mousepointer_location)
-
void ClearMarks()
Clears all initialized marks.
Marks can be manipulated by calling methods from their class.
- Move(Vector3 target)
- SetColor(Color c)
- Clear()
Example:
m = Besiege.CreateMark(Vector3(1, 1, 1))
m.Move(Vector3(2, 2, 2))
m.SetColor(Color(0, 1, 0)) #green
m.Clear()Tutorials
Guides to scripting from basic to advanced.
Installation
Required file structure.
Running scripts
Get started; how to run scripts and how to import / export them.
Block identifiers
How to select blocks.
Block handlers
Manipulating blocks.
Functions
All available functions.
Property identifiers
How to select block properties.
Watchlist
How to debug your script.
API
How to integrate with your mod.
Console commands
Mod configuration and Python console commands.
Fueled by coffee
