Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Computer Cart (Component)

feldim2425 edited this page Mar 24, 2016 · 15 revisions

This component is automatically added if you place a computer cart and it provides all functions to controll the break and the engine. The component is called "computercart" in the component list.

####Lua functions: #####Minecart control methods:

  • setBrake(enable:boolean):boolean, string enables / disables the brake and returns the new mode and a string if it failed.
  • getBrake():boolean returns true if the brake is enabled.
  • getEngineSpeed():number returns the current speed of the engine.
  • getCartSpeed():number returns the current speed of the cart.
  • setEngineSpeed(speed:number):number set the speed of the engine 0.0 is off, returns the new speed.
  • getMaxSpeed():number get the max. speed of the cart (not of the rail!).
  • setLightColor(color:number) set the color of the light.(0xRRGGBB) example.: 0xFFFFFF(while) 0xFF0000(red)
  • getLightColor():number get the color of the light.
  • rotate() rotate the cart by 180 degrees
  • onRail():boolen Check if the cart is on a rail.
  • hasNetworkRail():boolean Check if the cart is connected to a network rail.
  • isLocked():boolean Check if the cart is locked on a track

#####Inventory methods:

  • inventorySize():number The size of this device's internal inventory.
  • select([slot:number]):number Get the currently selected slot; set the selected slot if specified.
  • count([slot:number]):number Get the number of items in the specified slot, otherwise in the selected slot.
  • space([slot:number]):number Get the remaining space in the specified slot, otherwise in the selected slot.
  • compareTo(otherSlot:number):boolean Compare the contents of the selected slot to the contents of the specified slot.
  • transferTo(toSlot:number[,amount:number]):boolean Move up to the specified amount of items from the selected slot into the specified slot.
  • drop(side:number[, count:number=64]):boolean Drops items from the selected slot towards the specified side.
  • suck(side:number[, count:number=64]):boolean Suck up items from the specified side.

#####Tank methods:

  • tankCount():number The number of tanks installed in the device.
  • selectTank([index:number]):number Select a tank and/or get the number of the currently selected tank.
  • tankLevel([index:number]):number Get the fluid amount in the specified or selected tank.
  • tankSpace([index:number]):number Get the remaining fluid capacity in the specified or selected tank.
  • compareFluidTo(index:number):boolean Compares the fluids in the selected and the specified tank. Returns true if equal.
  • transferFluidTo(index:number[, count:number=1000]):boolean Move the specified amount of fluid from the selected tank into the specified tank.
  • compareFluid(side:number):boolean Compare the fluid in the selected tank with the fluid on the specified side. Returns true if equal.
  • drain(side:number[, amount:number=1000]):boolean, number or string Drains the specified amount of fluid from the specified side. Returns the amount drained, or an error message.
  • fill(side:number[, amount:number=1000]):boolean, number or string Eject the specified amount of fluid to the specified side. Returns the amount ejected or an error message.

NOTE: The computer cart can not place or take fluid blocks. This function would be useless because fluids destroy rails.

####Signals/Events:

  • inventory_changed():number called when a item in the main inventory changed. args.: number:slotnumber.
  • engine_failed():number called when the engine shut down wihout calling setEngineSpeed(). For Example if there is not enougth energy left. args: number:enginspeed.
  • track_state():boolean called when the cart moved on a track or leaved a track. args.: boolean:onrail.
  • network_rail():boolean called when a netowrk rail connects or disconnects. args.: boolean:connected.
  • cart_lockdown():boolean called when the cart gets locked/released on/from a Railcraft track. args.: boolean:locked