Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Forum Connectivity Upgrade Read more... ×
  • 1
LORD MJ

Help with wireless redstone

Question

Hello everyone.

First of all, since this is my first post, I would like to say a big congrats to the dev team of OpenComputers. For me it's definitely one of the most interesting mods for Minecraft and I like the idea behind it a lot.

Now for my question. Over the past few days, I've been working on my first program. I never programmed in Lua, so this was quite a challenge for me. I managed to get my program working the way I want it to, but I would like to make one more improvement for it.

The program is supposed to do one thing when it receives a wireless redstone signal on a certain frequency, and another thing when it receives a signal on a different frequency. The way I have it set up right now is with two Wireless Receivers from Wireless Redstone - CBE. One is connected on the left side of the computer and the other is connected on the right side of the computer.

I would like to use the Redstone Card Tier 2 that sits in my computer. I want to get rid of my Wireless Receivers. As I understand, the Redstone Card Tier 2 should be able to handle wireless redstone natively, but I can't figure out how to use the API correctly. I want to learn how to use this, as I'm sure I will use it a lot in my future programs.

Can someone help me by posting some code snippets I can implement? To reiterate, the computer needs to listen for a redstone signal on a certain frequency, do one thing if it receives a signal from one frequency and another thing if it receives a signal from another frequency.

Thank you.

Share this post


Link to post
Share on other sites

17 answers to this question

Recommended Posts

  • 1

From my glance at the wiki it appears you would need 2 redstone cards in that computer, one for each frequency.

 image.png.1e7da96e71246673d75b3548f983f527.png

You can only appear to set one frequency at a time. 

However as I'm writing this a possible workaround would be to have a loop running that checks the wireless state and switches the frequency, so something along the lines of this:

while true do -- not a great idea, change it so it has a condition
  redstone.setWirelessFrequency(freq1) -- Set first frequency
  local input = redstone.getWirelessInput()
  if input == whatever then
    -- do stuff
  end
  redstone.setWirelessFrequency(freq2) -- Set second frequency
  local input = redstone.getWirelessInput()
  if input == whatever then
    -- do more stuff
  end
  os.sleep(1) -- Sleep for 1 second, it might be in miliseconds so in that case change it to 1000. I can't remember right now
end

 

Share this post


Link to post
Share on other sites
  • 0

Thanks for the reply, @ZefTheFox.

Your idea sounds neat, but It would require me to rewrite my whole program. Probably doable, but I would like to keep it as it is, as I have tested it and it works.

However, your reply did make me do some digging, so I looked a bit closer at the API.

The way my program is written right now, I think I can get away with using only one card. At startup the program listens for the first signal. When it receives the signal, it jumps into a loop until it receives another signal.

The trouble I'm having is that I can't figure out how to use the redstone API correctly. I can't seem to access my Tier 2 card.

How do you do that? Can someone post a code snippet explaining step by step how is this done?

Share this post


Link to post
Share on other sites
  • 0

The issue you may* be having is that you have multiple redstone components and thus simply grabbing the default proxy (rs = component.redstone) you may be getting variable results or simply not the intended one. To see all the components of a certain type you can run the `components <component_type>` command. i.e `components redstone`. See below for getting specific proxies for specific components.

local component = require 'component'
local rsProxy = component.proxy 'XXXX-XXXXXXXX-XXXXXXXX-XXXXXX-XXXX' --# the Xs' are the full component address as a string

 

Share this post


Link to post
Share on other sites
  • 0

@Molinko I don't have multiple cards. My computer only has the necessary components it needs to run, plus a single Redstone Card Tier 2 and a Debug Card that is required for my program.

I actually made an entirely new computer so I can do some testing with the Redstone Card Tier 2, but I can't get any of the Wireless methods listed in the API to work. And I can't find a tutorial anywhere on the internet on how to set it up correctly.

Share this post


Link to post
Share on other sites
  • 0

If you setup two identical computers and make a simple script for each, one tx and one rx, to see if you can even transmit or receive even a single bit would be helpful I imagine. If possible then please post back so I can move forward on the assumption that it at least is feasible.

Share this post


Link to post
Share on other sites
  • 0

@Molinko Sure, I would love to help. But keep in mind, I'm a total newbie when it comes to OpenComputers, so I have no idea how to set up the thing you asked me. You will have to help me out and post the scripts.

Besides, I highly doubt that there is something wrong with OC. It's more likely that I'm just not setting things up correctly. I've tried to run some of the methods in the LUA interpreter and I couldn't get them to work. It's most likely that I can't format the command correctly.

If you could post a working snippet of code that does what I want then I can test it in my game. And it's probably going to work flawlessly.

Share this post


Link to post
Share on other sites
  • 0

Computer #1

lua> component.redstone.setWirelessFrequency(1)
lua> event.pull('redstone')
lua> component.redstone.getWirelessInput() > 0 --# wait to run this command 'til after commands on computer 2 are run

Computer #2

lua> component.redstone.setWirelessFrequency(1)
lua> component.redstone.setWirelessOutput(true)

These commands are meant to be run in the live Lua interpreter. Start with computer 1, wait to input line #3 until after commands on computer #2 are run. Once line 3 is executed you should see a `true` if the input is greater than zero from computer 2. I cant test this so.... Goodluck

Share this post


Link to post
Share on other sites
  • 0

@LORD MJ You do have t2 Redstone card in the computer, right? Could you also give us some details on what mod versions you have. MC version, of version and wr-cbe version numbers. I'm suspecting a incompatibility between mods, if it isn't the a problem with Redstone cards missing. 

 

 

Share this post


Link to post
Share on other sites
  • 0

@SpaceBeeGaming A bit unrelated, at first I read that I have 12 Redston Cards in my computer. And I'm like, that's not right! :lol:

I have a Redstone Card T2 in my computer. As for MC version, it's 1.12.2. And for the rest of the mods I'm running, here is a picture.

I know that OC recently had an update, but I'm not updating unless I'm instructed to do so.

Annotation 2018-11-17 232826.jpg

Share this post


Link to post
Share on other sites
  • 0

`setWirelessFrequency` was a method for rednet wireless redstone, which integration was removed in and after 1.11. in 1.12 we only have redstone and bundled redstone

also, updating is a great idea :) a whole lot was fixed, This is a patch release intended to fix a lot of issues

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, payonel said:

`setWirelessFrequency` was a method for rednet wireless redstone, which integration was removed in and after 1.11. in 1.12 we only have redstone and bundled redstone

also, updating is a great idea :) a whole lot was fixed, This is a patch release intended to fix a lot of issues

If this is the case, it needs to be addressed in the wiki. 

Share this post


Link to post
Share on other sites
  • 0

@payonel Okay, so if I understand this correctly, there are no methods to interact with Wireless Redstone CBE directly inside OC? If not, are there any plans to add this integration?

Also, I looked at "redstone.lua" inside the bin folder and found some references to Wireless Redstone, including setWirelessFrequency. I guess these methods are just there, but they don't work? Just curious.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

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