Jump to content




Touch Screen openblocks Radio Controller v1.1.2


33 replies to this topic

#1 OReezy

  • Members
  • 91 posts

Posted 06 March 2014 - 07:33 AM

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.


#2 unobtanium

  • Members
  • 505 posts

Posted 06 March 2014 - 11:13 AM

This is very well made :)

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 06 March 2014 - 12:09 PM

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.


#4 OReezy

  • Members
  • 91 posts

Posted 07 March 2014 - 06:00 AM

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.

#5 Godkyra

  • New Members
  • 2 posts

Posted 08 March 2014 - 10:13 PM

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.

#6 Dog

  • Members
  • 1,177 posts
  • LocationEarth orbit

Posted 09 March 2014 - 04:40 AM

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?

#7 OReezy

  • Members
  • 91 posts

Posted 09 March 2014 - 05:53 AM

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.

#8 Dog

  • Members
  • 1,177 posts
  • LocationEarth orbit

Posted 09 March 2014 - 05:39 PM

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

Edited by Dog, 09 March 2014 - 10:25 PM.


#9 Godkyra

  • New Members
  • 2 posts

Posted 09 March 2014 - 08:22 PM

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).

#10 willwac

  • Members
  • 182 posts

Posted 10 March 2014 - 12:19 AM

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?

#11 OReezy

  • Members
  • 91 posts

Posted 10 March 2014 - 02:57 AM

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.


#12 OReezy

  • Members
  • 91 posts

Posted 10 March 2014 - 07:25 PM

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()


#13 willwac

  • Members
  • 182 posts

Posted 12 March 2014 - 02:31 PM

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.


#14 OReezy

  • Members
  • 91 posts

Posted 12 March 2014 - 08:18 PM

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.

#15 willwac

  • Members
  • 182 posts

Posted 12 March 2014 - 09:23 PM

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.


#16 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 March 2014 - 10:14 PM

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.


#17 Fenric

  • New Members
  • 1 posts

Posted 16 March 2014 - 10:32 PM

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.

#18 FuzzyPurp

    Part-Time Ninja

  • Members
  • 510 posts
  • LocationHarlem, NY

Posted 17 March 2014 - 10:49 AM

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

#19 OReezy

  • Members
  • 91 posts

Posted 18 March 2014 - 01:02 AM

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.


#20 Ballistic Buddha

  • Members
  • 15 posts

Posted 21 March 2014 - 10:40 AM

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.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users