Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Question

2 answers to this question

Recommended Posts

  • 0
  • Solution

Hello! In order to use a redstone card the first thing you need to do is require the component library and set up a variable for the redstone card, using the following code:

local component = require("component")
local redstone = component.redstone

You will then have access to the redstone component, documentation for which is here: http://ocdoc.cil.li/component:redstone

 

You may also want to require the sides API, the code to do so looks like this:

local sides = require("sides")

This will give you access to the sides API, which lets you say "sides.top" or "sides.bottom" when using the redstone card, something that is very handy.

 

Documentation for this API is here: http://ocdoc.cil.li/api:sides

 

Here is some example code using the redstone component and the sides API to help you get started

local component = require("component") --require component in order to use the component API
local sides = require("sides")
local redstone = component.redstone -- create the variable "redstone" (which is shorter than typing out component.redstone)

redstone.setOutput(sides.bottom, 15) -- Set the redstone output on the bottom of the computer to 15, the maximum for vanilla redstone

local strength = redstone.getInput(sides.top) -- Set the new local variable "strength" to the strength of the redstone signal on top of the computer case

print(strength)

Hope you found this post helpful!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.