m

package
v0.0.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Target anything
	RTAny      = RadarTarget("any")
	RTEnemy    = RadarTarget("enemy")
	RTAlly     = RadarTarget("ally")
	RTPlayer   = RadarTarget("player")
	RTAttacker = RadarTarget("attacker")
	RTFlying   = RadarTarget("flying")
	RTBoss     = RadarTarget("boss")
	RTGround   = RadarTarget("ground")
)
View Source
const (
	RSDistance  = RadarSort("distance")
	RSHealth    = RadarSort("health")
	RSShield    = RadarSort("shield")
	RSArmor     = RadarSort("armor")
	RSMaxHealth = RadarSort("maxHealth")
)
View Source
const (
	BCore         = BlockFlag("core")
	BStorage      = BlockFlag("storage")
	BGenerator    = BlockFlag("generator")
	BTurret       = BlockFlag("turret")
	BFactory      = BlockFlag("factory")
	BRepair       = BlockFlag("repair")
	BRally        = BlockFlag("rally")
	BBattery      = BlockFlag("battery")
	BResupply     = BlockFlag("resupply")
	BReactor      = BlockFlag("reactor")
	BUnitModifier = BlockFlag("unitModifier")
	BExtinguisher = BlockFlag("extinguisher")
)

Variables

View Source
var (
	// A Building Object that represents the processor itself.
	// You can use this with sensor to find various properties about the processor.
	This = Building(nil)

	// The x coordinate of the processor.
	ThisX = 0

	// The y coordinate of the processor.
	ThisY = 0

	// The number of instructions executed per tick (60 ticks/second).
	//
	// Micro Processor -> 2
	// Logic Processor -> 8
	// Hyper Processor -> 25
	Ipt = 0

	// A variable that represents the next line the processor will read code from, equivalent to %IP in x86.
	// It can be changed like any other variable as another way to perform jumps.
	Counter = 0

	// A constant that equals the number of buildings linked to the processor.
	// It is changed by the processor when blocks are linked or unlinked.
	Links = 0

	// A constant that represents the current bound unit.
	// It only changes when the processor unbinds a unit, or binds another one.
	CurUnit = Unit(nil)

	// Represents the current UNIX timestamp in milliseconds.
	Time = 0

	// Represents the amount of ticks (60 ticks/second) since the map began.
	Tick = float64(0)

	// Width of the map, in tiles.
	MapW = 0

	// Height of the map, in tiles.
	MapH = 0
)
View Source
var PackageM embed.FS

Functions

func Abs added in v0.0.26

func Abs[A float](number A) float64

Return the absolute value of the input number

func Angle added in v0.0.26

func Angle[A float, B float](a A, b B) float64

Return angle of provided vector in degrees

func Ceil added in v0.0.11

func Ceil[A float](number A) int

Ceil the provided floating point number and convert to integer

func Const added in v0.0.12

func Const(constant string) string

Process provided string as a game constant

Example m.Const("@copper")

func ControlConfigure

func ControlConfigure[A integer](target Building, configuration A)

Set the configuration of the target building

func ControlEnabled

func ControlEnabled(target Building, enabled bool)

Enable/Disable a block e.g. conveyor, door, switch

func ControlShoot

func ControlShoot[A integer, B integer](turret Building, x A, y B, shoot bool)

Shoot with the provided turret at the target absolute position

If shoot parameter is false, it will cease firing

func ControlShootP

func ControlShootP(turret Building, target HealthC, shoot bool)

Smart version of ControlShoot

Shoot with the provided turret at the predicted position of target unit

If shoot parameter is false, it will cease firing

func Cos added in v0.0.26

func Cos[A float](number A) float64

Return the cosine of the input number in degrees

func DrawClear

func DrawClear[A integer, B integer, C integer](r A, g B, b C)

Fill the display with the provided color

func DrawColor

func DrawColor[A integer, B integer, C integer, D integer](r A, g B, b C, a D)

Set the drawing color for future statements

func DrawFlush

func DrawFlush(targetDisplay string)

Flush all draw statements to the provided display block

func DrawImage

func DrawImage[A integer, B integer, C float, D float](x A, y B, image string, size C, rotation D)

Draw provided icon centered around the provided point

func DrawLine

func DrawLine[A integer, B integer, C integer, D integer](x1 A, y1 B, x2 C, y2 D)

Draw a line between 2 points

func DrawLinePoly

func DrawLinePoly[A integer, B integer, C integer, D float, E float](x A, y B, sides C, radius D, rotation E)

Draw an outlined equilateral polygon centered around the provided point

func DrawLineRect

func DrawLineRect[A integer, B integer, C integer, D integer](x A, y B, width C, height D)

Draw an outlined rectangle from the provided point with the provided width and height

func DrawPoly

func DrawPoly[A integer, B integer, C integer, D float, E float](x A, y B, sides C, radius D, rotation E)

Draw a filled equilateral polygon centered around the provided point

func DrawRect

func DrawRect[A integer, B integer, C integer, D integer](x A, y B, width C, height D)

Draw a filled rectangle from the provided point with the provided width and height

func DrawStroke

func DrawStroke[A integer](width A)

Set the line width for future line statements

Affects DrawLine, DrawLineRect and DrawLinePoly

func DrawTriangle

func DrawTriangle[A integer, B integer, C integer, D integer, E integer, F integer](x1 A, y1 B, x2 C, y2 D, x3 E, y3 F)

Draw a filled triangle between provided points

func Floor

func Floor[A float](number A) int

Floor the provided floating point number and convert to integer

func IntDiv added in v0.0.11

func IntDiv[A integer, B integer](a A, b B) int

Perform an integer division on provided numbers

func Len added in v0.0.26

func Len[A float, B float](a A, b B) float64

Return length of vector

func Log added in v0.0.26

func Log[A float](number A) float64

Return a log function of the input number

func Log10 added in v0.0.11

func Log10[A float](number A) float64

Return a log10 function of the input number

func Max added in v0.0.26

func Max[A float, B float](a A, b B) float64

Return largest of two provided numbers

func Min added in v0.0.26

func Min[A float, B float](a A, b B) float64

Return smallest of two provided numbers

func Noise added in v0.0.26

func Noise[A float, B float](a A, b B) float64

Return 2D simplex noise

func PrintFlush

func PrintFlush(targetMessage string)

Flush all printed statements to the provided message block

func Random

func Random[A float](max A) float64

Generate a random floating point number between 0 (inclusive) and max (exclusive)

func Read

func Read[A integer](memory string, position A) int

Read a float64 value from memory at specified position

func Sensor

func Sensor(block HealthC, sense string) float64

Extract information indicated by sense from the provided block

func SensorStr added in v0.0.26

func SensorStr(block HealthC, sense string) string

String equivalent of Sensor

func Sin added in v0.0.26

func Sin[A float](number A) float64

Return the sine of the input number in degrees

func Sqrt added in v0.0.26

func Sqrt[A float](number A) float64

Return the square root of the input number

func Tan added in v0.0.26

func Tan[A float](number A) float64

Return the tangent of the input number in degrees

func UnitApproach

func UnitApproach[A float, B float, C float](x A, y B, radius C)

Approach a circular radius around the provided point

Will stop moving once it is the provided radius away from the point

func UnitBind

func UnitBind(unitType string)

Load the next cached unit of the provided type into memory

Will loop over once it reaches the end of the cache

func UnitBoost

func UnitBoost(enable bool)

Enable/Disable boosting for mechs

func UnitBuild

func UnitBuild[A float, B float, C integer, D integer](x A, y B, block string, rotation C, config D)

Build a block at the specified absolute position

func UnitFlag

func UnitFlag[A float](flag A)

Set the units flag

Shown as a number when hovering over a unit

func UnitItemDrop

func UnitItemDrop[A integer](to Building, amount A)

Drops items into the provided building

Will not drop more than provided amount

func UnitItemTake

func UnitItemTake[A integer](from Building, item string, amount A)

Takes the provided item type from the provided building

Will not take more than provided amount

func UnitLocateOre

func UnitLocateOre(ore string) (x int, y int, found bool)

Locate a block of the provided ore type

Also locates blocks outside the range of the unit

func UnitMine

func UnitMine[A float, B float](x A, y B)

Mine the ore at the specified absolute position

Will not do anything if there is no minable ore or it is already being mined

func UnitMove

func UnitMove[A float, B float](x A, y B)

Move to the provided absolute position on the map

func UnitPathfind

func UnitPathfind()

Make the unit follow standard AI

Find enemy cores, guard spawns, obey command centers

func UnitPayloadDrop

func UnitPayloadDrop()

Drops the current payload

Will only drop blocks if there is an empty space

func UnitPayloadTake

func UnitPayloadTake(takeUnits bool)

Pick up payload from underneath the unit

If takeUnits is true, will also pick up units

func UnitStop

func UnitStop()

Stop all actions including shooting

func UnitTarget

func UnitTarget[A float, B float](x A, y B, shoot bool)

Like ControlShoot but for units

Shoot with the cached unit at the target absolute position

If shoot parameter is false, it will cease firing

Will not shoot outside of the units range!

func UnitTargetP

func UnitTargetP(target HealthC, shoot bool)

Like ControlShootP but for units

Shoot with the cached unit at the predicted position of target unit

If shoot parameter is false, it will cease firing

func UnitWithin

func UnitWithin[A float, B float, C float](x A, y B, radius C) bool

Checks whether there is a unit within the specified radius around the provided absolute position

func Write

func Write[A float, B integer](value A, memory string, position B)

Write a value to memory at specified position

Types

type BlockFlag

type BlockFlag = string

type Building

type Building = interface {
	HealthC
	Ranged

	// Gets total amount of liquids currently stored in the container(Building)
	GetTotalLiquids() float64

	// Gets the maximum amount of liquids stored in the container(Building)
	GetLiquidCapaticy() float64

	// In case of unbuffered consumers, this is the percentage (1.0f = 100%) of the demanded power which can be supplied.
	// Blocks will work at a reduced efficiency if this is not equal to 1.0f.
	// In case of buffered consumers, this is storage capacity.
	GetTotalPower() float64

	// In case of unbuffered consumers, this is the 0
	// n case of buffered consumers, this is the maximum storage capacity.
	GetPowerCapaticy() float64

	// Get the total power currently stored in the grid (Only machines connected to the grid)
	GetPowerNetStored() float64

	// Get the maximum power capacity in the grid (Only machines connected to the grid)
	GetPowerNetCapacity() float64

	// Get the input power of the current grid (Only machines connected to the grid)
	GetPowerNetIn() float64

	// Get the output power of the current grid (Only machines connected to the grid)
	GetPowerNetOut() float64

	// Get the heat from the machine (Just Thorium Reactor)
	GetHeat() float64

	//Get machine efficiency
	GetEfficiency() float64

	//Check whether the machine is available
	IsEnabled() bool
}

func B added in v0.0.20

func B(name string) Building

Return a building of the provided name

Example m.B("message1")

func UnitGetBlock

func UnitGetBlock[A float, B float](x A, y B) (blockType string, building Building)

Retrieve the building and its type at the specified absolute position

func UnitLocateBuilding

func UnitLocateBuilding(buildingType BlockFlag, enemy bool) (x int, y int, found bool, building Building)

Locate a building of the provided type

If enemy is true, derelict blocks cannot be located

Also locates blocks outside the range of the unit

func UnitLocateDamaged

func UnitLocateDamaged() (x int, y int, found bool, building Building)

Locate a damaged building

Also locates blocks outside the range of the unit

func UnitLocateSpawn

func UnitLocateSpawn() (x int, y int, found bool, building Building)

Locate the enemy spawn

Also locates blocks outside the range of the unit

type HealthC

type HealthC = interface {
	//Get the current health value of Unit or Building
	GetHealth() int

	//Gets the name of Unit or Building
	GetName() string

	//Get the X coordinate of Unit or Building
	GetX() float64

	//Get the Y coordinate of Unit or Building
	GetY() float64

	// Get the total number of items stored in Unit or Building
	GetTotalItems() int

	// Get the capacity of items stored in Unit or Building
	GetItemCapacity() int

	// Get the angle of view of Unit or Building
	GetRotation() float64

	// Get the X coordinate of Unit or Building's collimator
	GetShootX() float64

	// Get the Y coordinate of Unit or Building's collimator
	GetShootY() float64

	// Check whether Unit or Building fires
	IsShooting() bool
}
type Link = interface{}
func GetLink[A integer](address A) Link

Get the linked tile at the specified address

type RadarSort

type RadarSort = string

type RadarTarget

type RadarTarget = string

type Ranged added in v0.0.18

type Ranged = interface{}

type Unit

type Unit = interface {
	HealthC
	Ranged
}

func Radar

func Radar(from Ranged, target1 RadarTarget, target2 RadarTarget, target3 RadarTarget, sortOrder bool, sort RadarSort) Unit

Retrieve a list of units that match specified conditions

Conditions are combined using an `and` operation

func UnitRadar

func UnitRadar(target1 RadarTarget, target2 RadarTarget, target3 RadarTarget, sortOrder bool, sort RadarSort) Unit

Like Radar but originates from the cached units

Retrieve a list of units that match specified conditions

Conditions are combined using an `and` operation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL