←  Programs

ComputerCraft | Programmable Computers for Minecraft

»

Touch Screen openblocks Radio Controller v...

OReezy's Photo OReezy 06 Mar 2014

Here is a small program I wrote to control the radios from openblocks.

Version 1.1.1

Setup
  • For the actual build you just need the radio and chest to be adjacent to each other and you need an advanced monitor. When you run the program, it will set itself up and find all other information on its own. If something was set up incorrectly it will also tell you what went wrong.
  • For volume control, radio must be next to computer
  • CODE: http://pastebin.com/gfdZzLtv
  • pastebin get gfdZzLtv radio
Features
  • Automatically detects peripherals
  • Automatically indexes all disks in chest
  • Scrolling buttons in case there are more disks than screen space
  • Remembers which disk is being played and displays it in a different color
  • Volume control
  • Features only appear if they need to or if they are working (if radio is not next to computer it cannot control volume or if there are fewer disks than screen space)
  • Can specify which monitor to use
  • Can use Advanced Terminal
  • Prints setup info to terminal if in debug mode (see arguments)
  • Remembers custom settings entered with arguments
Arguments:
  • help Displays arguments in game on terminal
  • -t Terminal mode (Not available while using monitor mode)
  • -d Debug mode
  • -nd Non-daemon mode
  • -m<side or name> Specify which monitor to use (Only one monitor at a time for now)
  • -s<.5-5> Change scale of monitor (not available for terminals)
  • -v<1-15> Changes initial volume
Example: radio -mmonitor_5 -s3 -d

Possible Future Updates
  • Options menu for customization
  • Multi-monitor support
Screenshots

Changelog

If you find bugs, please post them here.

How to Add Stations

Edited by OReezy, 11 September 2014 - 01:39 AM.
Quote

unobtanium's Photo unobtanium 06 Mar 2014

This is very well made :)
Quote

theoriginalbit's Photo theoriginalbit 06 Mar 2014

I agree with UNOBTANIUM; looks quite nice and solid coding behind the scenes. If there was something that I'd pick on it would be a few minor things here and there and most are only for readability reasons

for example line 25
if not radio or not chest or not mon then
I'd make it
if not (radio and chest and mon) then

or the function detectRadioDisk
local function detectRadioDisk()
  local t = radio.getStackInSlot(1)
  return t and t.name or false
end

EDIT: Actually on second look that function isn't even used.
Edited by theoriginalbit, 06 March 2014 - 12:09 PM.
Quote

OReezy's Photo OReezy 07 Mar 2014

View Posttheoriginalbit, on 06 March 2014 - 12:09 PM, said:

I agree with UNOBTANIUM; looks quite nice and solid coding behind the scenes. If there was something that I'd pick on it would be a few minor things here and there and most are only for readability reasons

for example line 25
if not radio or not chest or not mon then
I'd make it
if not (radio and chest and mon) then

or the function detectRadioDisk
local function detectRadioDisk()
  local t = radio.getStackInSlot(1)
  return t and t.name or false
end

EDIT: Actually on second look that function isn't even used.

Thanks for the tips. That function was left over from I was testing to find the best ways to do things.
Quote

Godkyra's Photo Godkyra 08 Mar 2014

Hi there. :) I made an account just to say thank you for this. I found the radio the other day and immediately wanted to make a CC volume control for it (with no LUA knowledge). I look on here for info and found that you'd already done it. :P Thank you muchly.

I did have some issues though. For the entire script to work, the chest must be next to both the Computer and the Radio. If the chest and Radio are next to the Computer, they can't touch each other, so the script fails. Is this intended?

I got around it by placing the chest behind the Radio, and using a preripheral proxy to link the chest to the Computer. The script ran beautifully then. (Pics below)

https://www.dropbox....4i1p/Radio1.png
https://www.dropbox....bnfq/Radio2.png

Once again: Much Appreciated.
Quote

Dog's Photo Dog 09 Mar 2014

I'm having the same issue as Godkyra, but using the peripheral proxy isn't working for me - the program still says the chest isn't next to the radio even though it is :\ Any suggestions?
Quote

OReezy's Photo OReezy 09 Mar 2014

View PostDog, on 09 March 2014 - 04:40 AM, said:

I'm having the same issue as Godkyra, but using the peripheral proxy isn't working for me - the program still says the chest isn't next to the radio even though it is :\ Any suggestions?

Make sure there is a disk in the chest or radio. It you do have a disk in the chest, make sure it is in the first slot as that is the slot my program uses to test if the chest and radio are adjacent. If this doesn't help, could you send me a picture of your setup?

Also, you can get the chest/radio/computer all touching if you use a vanilla double chest. From a top down view it would look like this:
C = chest, R = radio, U = computer
CC
UR


View PostGodkyra, on 08 March 2014 - 10:13 PM, said:

Hi there. :) I made an account just to say thank you for this. I found the radio the other day and immediately wanted to make a CC volume control for it (with no LUA knowledge). I look on here for info and found that you'd already done it. :P Thank you muchly.

I did have some issues though. For the entire script to work, the chest must be next to both the Computer and the Radio. If the chest and Radio are next to the Computer, they can't touch each other, so the script fails. Is this intended?

I got around it by placing the chest behind the Radio, and using a preripheral proxy to link the chest to the Computer. The script ran beautifully then. (Pics below)

https://www.dropbox....4i1p/Radio1.png
https://www.dropbox....bnfq/Radio2.png

Once again: Much Appreciated.

Thanks, glad I could help. It was quite fun to code. I also plan to add some new features once I am not so busy. (Probably after this next week)

With a single chest it is impossible to have all three touching. There isn't a way around this as that is simply how the game works. I use a vanilla double chest for mine so I can keep it compact.
Quote

Dog's Photo Dog 09 Mar 2014

Got it working - was using the wrong 'disks' (facepalm)
Edited by Dog, 09 March 2014 - 10:25 PM.
Quote

Godkyra's Photo Godkyra 09 Mar 2014

I tried removing the Modems and Proxy, then replacing them with a double chest. The setup worked perfectly as OReezy said it would.

I don't know what texture pack you're using, but you don't appear to be working with an Advanced computer. Likewise you will want the advanced monitors (If you are using both then my bad, ignore that).

Also, you say you're using discs? Try using a tuner card (you will need to put a radio station in your configs for one to show up, if you haven't already).
Quote

willwac's Photo willwac 10 Mar 2014

This is great! I recomend changing the color of the scroll buttons and changing the "OFF" button to "QUIT" or "EXIT" when nothing is playing.
Or how about a debian?
Quote

OReezy's Photo OReezy 10 Mar 2014

View PostDog, on 09 March 2014 - 05:39 PM, said:

Got it working - was using the wrong 'disks' (facepalm)

I was thinking about asking this but it felt silly, sorry :P

View Postwillwac (NewCoolPC), on 10 March 2014 - 12:19 AM, said:

This is great! I recomend changing the color of the scroll buttons and changing the "OFF" button to "QUIT" or "EXIT" when nothing is playing.
Or how about a debian?

Thanks. I am thinking of adding an options menu for changing all the colors. I don't know if I will make the "OFF" button change to "EXIT" because it seems like it could be clicked on accident on small monitor setups pretty easily. If I do make an options menu though, I will probly add it as an option to turn that on.

And whats a debian?
Edited by OReezy, 10 March 2014 - 03:01 AM.
Quote

OReezy's Photo OReezy 10 Mar 2014

Update: v1.0.1
  • Added an additional check for wrong disk type
  • Updated initialEmpty() to find the first open slot in a chest instead of attempting all slots until it comes across an empty slot
  • Removed unnecessary function getRadioDisk()
Quote

willwac's Photo willwac 12 Mar 2014

View PostOReezy, on 10 March 2014 - 02:57 AM, said:

And whats a debian?
Sorry, I ment daemon.
Basiclly, run it on the monitor, yet allow users to use the shell.
Also, I had a few ideas.
Spoiler

Edited by willwac (NewCoolPC), 01 October 2014 - 12:42 AM.
Quote

OReezy's Photo OReezy 12 Mar 2014

View Postwillwac (NewCoolPC), on 12 March 2014 - 02:31 PM, said:

View PostOReezy, on 10 March 2014 - 02:57 AM, said:

And whats a debian?
Sorry, I ment daemon.
Basiclly, run it on the monitor, yet allow users to use the shell.
Also, I had a few ideas.
Spoiler

I really like this idea. Going to have to look into daemons. I am already planning to make a terminal version as well.
Quote

willwac's Photo willwac 12 Mar 2014

Basicly, to do a daemon, you just do this:
local function myProg()
  --code--
end

local function shellMe()
  shell.run("/rom/programs/shell") --You don't have to use the direct path, but it clears up some confusion.'
end

parallel.waitForAll(myProg(),shellMe())

Edited by willwac (NewCoolPC), 12 March 2014 - 09:24 PM.
Quote

theoriginalbit's Photo theoriginalbit 12 Mar 2014

View PostOReezy, on 12 March 2014 - 08:18 PM, said:

View Postwillwac (NewCoolPC), on 12 March 2014 - 02:31 PM, said:

Also, I had a few ideas.
Spoiler
I really like this idea. Going to have to look into daemons. I am already planning to make a terminal version as well.
Personally this is what I've found to be the best method of implementing runtime args like willwac has suggested (+ one of my own thoughts)
code

Edited by theoriginalbit, 12 March 2014 - 10:15 PM.
Quote

Fenric's Photo Fenric 16 Mar 2014

Hello,

I found this thread while searching for a way to control the volume on OpenBlocks radio stations in game. Since it's quite recent I wanted to register and post as it's not working for me.

Here's how I placed everything:
http://imgur.com/a/2dDNI#0

I'm returning to Minecraft and learning mods so not sure if I'm missing something obvious. I'm using The MadPack if that matters.

Hi again,

My last post still hasn't shown up as I just registered on the site and it has to be approved. I'm hoping this post will at least get through.

I figured out why it was not working. MadPack did not have the OpenBlocks Peripheral Addons included.

It's working great now, thanks a lot for posting this.
Quote

FuzzyPurp's Photo FuzzyPurp 17 Mar 2014

View PostFenric, on 16 March 2014 - 10:32 PM, said:


Here's how I placed everything:
http://imgur.com/a/2dDNI#0


Here is a way to fix that spacing and dot on CC screens while using Sphax texture pack.
http://bdcraft.net/c...g-bug-t773.html
Quote

OReezy's Photo OReezy 18 Mar 2014

View PostFenric, on 16 March 2014 - 10:32 PM, said:

It's working great now, thanks a lot for posting this.

I'm glad you like it.

Udate: 1.1.0
  • Advanced Terminal support
  • Can specify which monitor to use
  • Now runs in background
  • Accepts arguments
Arguments:
  • -t Terminal mode
  • -nd Non-Daemon mode
  • -d Debug mode
  • -m<side or name> Specify a monitor to use
  • -s<.5-5> Sets scale of monitor (not available for terminal)

Edited by OReezy, 18 March 2014 - 02:32 AM.
Quote

Ballistic Buddha's Photo Ballistic Buddha 21 Mar 2014

Hah, wow. I actually just made myself a program for radio control, I knew I should have checked the forums first :P. However, I've got to say yours is much better. Not only does your main monitor output look better, but you also included cli flags and the ability to swap out crystals.

This is what mine looks like

Now, Since I'm still a fan of the big ass vertical monitor for volume control, I feel inclined to merge my code with yours. I took a quick peek at your code and it looks pretty neat and organized, so it shouldn't be all that hard to do.

So thank you for this, thanks a lot :)
Edited by Ballistic Buddha, 21 March 2014 - 10:41 AM.
Quote