Function Event

Get some context about the current crafting process

Function event is the object provided in the function requirement event using the KubeJS integration.

It contains various methods for interacting with the machine.

Get the remaining crafting time

Name : remainingTime

Description :

Return a decimal value that represent the time in ticks before the end of the current recipe process. This value does not take into account any speed modifiers applied to the machine.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

.requireFunctionEachTick(ctx => {
		let time = ctx.remainingTime;
                //Use time here
	})
Get the crafting process base speed

Name : baseSpeed

Description :

Return a decimal value that represent the base speed (before upgrades are applied) of the crafting process.

By default it returns 1

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

.requireFunctionEachTick(ctx => {
		let baseSpeed = ctx.baseSpeed;
                //Use baseSpeed here
	})
Set the crafting process base speed

Name : baseSpeed

Description :

Set a decimal value as the base speed (before upgrades are applied) of the crafting process.

The new speed must not be negative.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example :

.requireFunctionOnStart(ctx => {
		ctx.baseSpeed = 2;
	})
Get the crafting process modified speed

Name : modifiedSpeed

Description :

Return a decimal value that represent the modified speed (after upgrades are applied) of the crafting process.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

.requireFunctionEachTick(ctx => {
		let modifiedSpeed = ctx.modifiedSpeed;
                //Use modifiedSpeed here
	})
Get the machine as a tile entity

Name : tile

Description :

Return a TileEntity, you can use it to get various informations about the machine (couldn't find KubeJS docs for that one sorry).

Example

.requireFunctionEachTick(ctx => {
		let tile = ctx.tile;
                //Use tile here
	})
Get the machine as a custom machine

Name : machine

Description :

Return a Machine, you can use it to check, input and output energy, fluids and items from/to the machine.

Example

.requireFunctionEachTick(ctx => {
		let machine = ctx.machine;
                //Use machine here
	})
Get the machine as a BlockContainerJS

Name : block

Description :

Return a BlockContainerJS, the KubeJS representation of a block placed in world.

Example

.requireFunctionEachTick(ctx => {
		let block = ctx.block;
                //Use block here
	})

Last updated