Skip to content

Documentation

wolfieboy09 edited this page May 8, 2024 · 7 revisions

Welcome to the KubeJS + CC: Tweaked wiki! Here is where everything is

Tip

ComputerCraftEvents.peripheral(function (event) {}) has to be put inside a KubeJS startup script. Also, read this super useful!!

PeripheralRegisterEvent functions

  • event.registerPeripheral(type, blockStateMatcher)
    type: string The peripheral type name of your choice
    blockStateMatcher: string | RegExp A string or regular expression to match against one or multiple block ids (e.g.: "minecraft:furnace" or /^modid:.*_pulverizer$/).

  • event.registerComplexPeripheral(type, blockTester)
    type: string The peripheral type name of your choice
    blockTester: function(BlockContainerJS block) {} A function that will test the block (BlockContainerJS) against one ore more conditions to write inside. The provided function must return true or false to be valid.

Both of those Event functions return a Peripheral (see next section below).

Peripheral (PeripheralJS) functions

  • method(name, methodFunction)
  • mainThreadMethod(name, methodFunction)

Both of these functions share the same parameters:
name: string: the name of the method you want to declare on this peripheral
methodFunction: function(block, side, args, computer, context) {}: the function code that will be executed when the peripheral method is called by a turtle/computer.

methodFunction function parameter types:

  • block: BlockContainerJS: the peripheral block, see KubeJS BlockContainerJS code.
  • side: Direction: the side from which the peripheral is attached, see minecraftforge Direction java docs. In your JS code you can also use Direction global variable provided by KubeJS (code)
  • args: array[]: a javascript Array containing the arguments provided when calling the method
  • computer: IComputerAccess: the computer instance from which the method was called, you shouldn't need to use it, but it's there if you need it. See IComputerAccess java code.
    context: ILuaContext: lua context instance in case you need it at some point (you won't). See ILuaContext java code.

Clone this wiki locally