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

Adding a color to Bundled Output

Question

I'm trying to figure out how to add and remove a single color from the bundled output of the computer. This is what I was trying to do:

local component = require("component")
local sides = require("sides")
local colors = require("colors")
local rs = component.redstone

function addcol(sid, col)
  local t = rs.getBundledOutput(sides.sid)
  table.insert(t, colors.col)
  rs.setBundledOutput(sides.sid, t, 15)
end

function remcol(sid, col)
  local t = rs.getBundledOutput(sides.sid)
  table.remove(t, colors.col)
  rs.setBundledOutput(sides.sid, t, 15)
end

However, this doesn't seem to work at all. If anyone had some insight and could help me figure out the solution to my problem, I would be very grateful.

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1
  • Solution

getBundledOutput does not return a table, sadly there is no way to get the entire bundled output in 1 call.

However that doesn't mean this is impossible, it's actually way easier than you think, you are just using the alternate version of setBundledOutput.
According to the docs the first version of setBundledOutput takes side, color, value. So you really don't need functions to do this, but if you're still unsure here is the fixed version.

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

function addcol(sid, col)
  rs.setBundledOutput(sid, col, 15)
end

function remcol(sid, col)
  rs.setBundledOutput(sid, col, 0)
end

Also while I was able to understand the attempt in your code, it was both syntactically and logically wrong. You tried to reference your variables by prepending the table which contains the type, and the function arguments were completely wrong. I'd suggest you watch/read a few Lua and OC tutorials, and most importantly read the docs.

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.