Jump to content




Umaroth's Power Monitor

lua peripheral game

25 replies to this topic

#1 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 30 March 2015 - 05:58 AM

Description:

A script designed to monitor Energy Cells and Capacitor Banks and turn engines/reactors/turbines on/off depending on energy levels. This is designed to be fully configurable and expandable.

Requires Computronics or OpenPeripheralsIntegration!

Images:
Spoiler

Features:
  • Dynamically controls engines, turbines and reactors based on how much energy is stored in connected energy storage blocks.
  • Energy values at which to turn engines on and off are easily configurable.
  • Can output redstone to any side or no side with easy configuration. (For controlling engines)
  • Automatic detection of any peripherals connected to the computer, either through direct contact or through a wired network.
  • Automatically detects and controls connected Turbines/Reactors.
  • Accepts connections to as many monitors and energy storage cubes as the network can support. (I haven't found the limit yet, if there is one.)
  • Supports two monitors sizes: 1x2 and 2x3. (HxW)
  • Supports billions of RF. Anything less than 1 trillion RF will fit on the screen.
  • Features a capacity bar on the right side of the screen on 3v2 monitors.
Limitations:
  • Only officially supports Energy Cells and Capacitor Banks. Mekanism Energy Cubes work, but aren't officially supported because they don't use RF. (They also only work if you have Computronics)
  • Only officially reads RF, other types may be added in the future if there is demand.
  • Can only control one turbine and one reactor. I could add support for more but I doubt anyone uses more than one of each.
  • If you don't have Computronics then Capacitor Banks aren't fully supported. You must manually specify how many blocks are in the Capacitor Bank within the program and it only works properly for one Capacitor Bank. It may be inaccurate at times as well due to uneven RF distribution among the blocks of the Capacitor Bank.
  • Requires at least one monitor and all monitors must be either 1x2 or 2x3 in size. I could add support for no monitors if needed.
  • Can only output redstone to one side but I doubt that's an issue.
Suggestions:

I'm open to any and all suggestions, if there's a mod you want me to support or a new storage block or energy type you want it to read or feature you want me to add, please let me know.

Bugs:

I had to make a lot of changes to implement compatibility with both OpenPeripherals and Computronics and I haven't had time to fully test this version, so please consider version 1.3 beta until I've had time to fully test it. That being said I'm not currently aware of any bugs.

Planned Features:
  • Anything possible/feasible that is suggested.
Get the code here: http://pastebin.com/cA2TNNdH

Read the Changelog/Readme here: http://pastebin.com/erPf3t4t

Background:

This script is based on one posted here.

I liked the idea of that script but I found it extremely lack-luster. It only supported one monitor and one energy storage block at a time, it only supported one monitor size, the redstone output side wasn't configurable and anything over a billion RF didn't fit on the screen. Oh yeah, and it didn't even work anymore with the current mod versions.

Enjoy!

This script was developed using Minecraft v1.7.10, Thermal Expansion 4.0.0RC7, EnderIO v2.2.8, Computercraft 1.73, Computronics v1.4.4 ,OpenPeripherals 1.7.10-AIO-2 and BigReactors 0.4.2A2.

Edited by Umaroth, 06 April 2015 - 05:08 AM.
removed redirecting link


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 March 2015 - 03:30 PM

Shortened/redirecting links are not allowed. I've removed the tinyurl link and replaced it with a formatted link to the old link's final destination.

#3 Kaidenyo

  • Members
  • 11 posts

Posted 01 April 2015 - 11:41 AM

Says "No RF Storage found. Exiting Script!"

Setup Here: http://i.imgur.com/V6UTlOZ.png

These are normal Capacitor banks ( 5m Storage )

Edited by Kaidenyo, 01 April 2015 - 11:44 AM.


#4 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 01 April 2015 - 01:20 PM

in the OP, the controlling computer has one modem, combine your cables and remove a modem, see if that works

#5 Kaidenyo

  • Members
  • 11 posts

Posted 01 April 2015 - 08:29 PM

View PostLupus590, on 01 April 2015 - 01:20 PM, said:

in the OP, the controlling computer has one modem, combine your cables and remove a modem, see if that works

Does not work, sadly


I got it working by changing the code from "capacitor_bank" to "tile_blockcapacitorbank_name". I have the same Version of Mods as OP stated, so im not sure why its different. peripheralget also returned tile_blockcapacitorbank_name.

It also does not take more than the block it has the peripheralwrap on into consideration. My Capacitors have 185m RF Storage room, but the output only shows 5m RF ( which is one block )

Edited by Kaidenyo, 01 April 2015 - 09:16 PM.


#6 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 01 April 2015 - 10:07 PM

View PostKaidenyo, on 01 April 2015 - 08:29 PM, said:

I got it working by changing the code from "capacitor_bank" to "tile_blockcapacitorbank_name". I have the same Version of Mods as OP stated, so im not sure why its different. peripheralget also returned tile_blockcapacitorbank_name.

It also does not take more than the block it has the peripheralwrap on into consideration. My Capacitors have 185m RF Storage room, but the output only shows 5m RF ( which is one block )

Let me make sure I have an official version of the program uploaded to Pastebin, I tend to upload testing versions to it for easy importing to Computercraft, I'll have to be sure to use a separate Pastebin upload for that from now on.

Also, I'd like to know why your peripheral name was different. I don't know what assigns those names. But that's why I posted all my mod versions, so people could compare theirs to mine and let me know so I can figure out which versions require a code change.

Also, it's strange that the program only counts the energy in one block of the Cap. Bank because it reads the entire thing for mine no matter what block I connect it to and no matter how large the capacitor bank is. Are you sure you're on the same mod versions? This problem is pretty bizarre.

Update: After some research it looks like it's OpenPeripherals that assigns types to everything aside from core Computercraft Peripherals, so that is what would have to be the same version as mine in order to work.

Let me test something: I'm going to install the standalone versions of OpenPeripherals instead of the AllInOne version and see if that makes a difference.

Update 2: It didn't make a difference, every peripheral still has the same peripheral.getType() return for me as it did before.

Also, I checked the version uploaded to Pastebin and it's a correct version, there shouldn't be any extraneous bugs in it.

Edited by Umaroth, 02 April 2015 - 04:17 AM.


#7 isaokirito

  • New Members
  • 2 posts

Posted 01 April 2015 - 10:16 PM

How do I actually get this onto a computer itself I am kinda newby maybe a video showing how idk I don't know how to do this and I really want this thanks.

#8 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 02 April 2015 - 03:36 AM

View Postisaokirito, on 01 April 2015 - 10:16 PM, said:

How do I actually get this onto a computer itself I am kinda newby maybe a video showing how idk I don't know how to do this and I really want this thanks.

I put how to do it in the Changelog/Readme posted here: http://pastebin.com/erPf3t4t

Here is what is says:

Quote

To get this on your CC computer type/copy this into your Computercraft terminal:

pastebin get cA2TNNdH PowerMonitor

It should succeed if you are connected to the internet, then you can run the program by typing "PowerMonitor" into the computer.

Then, if you want the program to run automatically, type/copy this into the computer:

rename PowerMonitor startup

View PostLupus590, on 01 April 2015 - 01:20 PM, said:

in the OP, the controlling computer has one modem, combine your cables and remove a modem, see if that works

I haven't tried more than one connected network (mostly because I can't think of a reason to have more than one), but theoretically it shouldn't make a difference, computers can connect to more than one network at a time, all device names should still be unique. There's nothing in the code limiting it to only one network.

Edited by Umaroth, 02 April 2015 - 03:45 AM.


#9 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 02 April 2015 - 03:46 AM

View PostLupus590, on 01 April 2015 - 01:20 PM, said:

in the OP, the controlling computer has one modem, combine your cables and remove a modem, see if that works

I haven't tried more than one connected network (mostly because I can't think of a reason to have more than one), but theoretically it shouldn't make a difference, computers can connect to more than one network at a time, even across separate networks all device names should still be unique and there's nothing in the code limiting it to only one network, so the script should recognize and connect to everything.

Edited by Umaroth, 02 April 2015 - 03:48 AM.


#10 Kaidenyo

  • Members
  • 11 posts

Posted 02 April 2015 - 07:36 AM

View PostUmaroth, on 01 April 2015 - 10:07 PM, said:

View PostKaidenyo, on 01 April 2015 - 08:29 PM, said:

I got it working by changing the code from "capacitor_bank" to "tile_blockcapacitorbank_name". I have the same Version of Mods as OP stated, so im not sure why its different. peripheralget also returned tile_blockcapacitorbank_name.

It also does not take more than the block it has the peripheralwrap on into consideration. My Capacitors have 185m RF Storage room, but the output only shows 5m RF ( which is one block )

Let me make sure I have an official version of the program uploaded to Pastebin, I tend to upload testing versions to it for easy importing to Computercraft, I'll have to be sure to use a separate Pastebin upload for that from now on.

Also, I'd like to know why your peripheral name was different. I don't know what assigns those names. But that's why I posted all my mod versions, so people could compare theirs to mine and let me know so I can figure out which versions require a code change.

Also, it's strange that the program only counts the energy in one block of the Cap. Bank because it reads the entire thing for mine no matter what block I connect it to and no matter how large the capacitor bank is. Are you sure you're on the same mod versions? This problem is pretty bizarre.

Update: After some research it looks like it's OpenPeripherals that assigns types to everything aside from core Computercraft Peripherals, so that is what would have to be the same version as mine in order to work.

Let me test something: I'm going to install the standalone versions of OpenPeripherals instead of the AllInOne version and see if that makes a difference.

Update 2: It didn't make a difference, every peripheral still has the same peripheral.getType() return for me as it did before.

Also, I checked the version uploaded to Pastebin and it's a correct version, there shouldn't be any extraneous bugs in it.

Hey we are using openperipherals from here http://www.openperipheral.info/ (3 seperate downloads). Modpack is here http://www.technicpa...ack.588534/mods

I dont know why its tile_blockblahblah instead of capacitor_bank. But having wrong information may come from the peripheralwrap itself, since its named "tile_blockcapablahlblah_nameX" and X indicates the number of the bank in the whole array with capabanks ( so it starts with 1 and ends with 38 in my example )

#11 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 02 April 2015 - 08:54 AM

View PostKaidenyo, on 02 April 2015 - 07:36 AM, said:

Hey we are using openperipherals from here http://www.openperipheral.info/ (3 seperate downloads). Modpack is here http://www.technicpa...ack.588534/mods

I dont know why its tile_blockblahblah instead of capacitor_bank. But having wrong information may come from the peripheralwrap itself, since its named "tile_blockcapablahlblah_nameX" and X indicates the number of the bank in the whole array with capabanks ( so it starts with 1 and ends with 38 in my example )

Hmm, can you check all of the peripheral names for me? Are you getting different types assigned to everything or just capacitor banks? The ones on my world are "powered_tile" (applies to both TE Energy Cells and Mekanism Energy Cubes, possibly others as well), and "BigReactors_Turbine".

Also, are you saying that if you have a 38 block capacitor bank, it's assigning a different network name to every block in the capacitor bank? That's very strange, especially since you have the exact same versions of Computercraft, OpenPI, and EnderIO as I do.

Oh, and I can't believe I didn't ask this earlier: Why does your capacitor bank have an Input/Output screen on it?

Edited by Umaroth, 02 April 2015 - 09:11 AM.


#12 Kaidenyo

  • Members
  • 11 posts

Posted 02 April 2015 - 05:50 PM

View PostUmaroth, on 02 April 2015 - 08:54 AM, said:

View PostKaidenyo, on 02 April 2015 - 07:36 AM, said:

Hey we are using openperipherals from here http://www.openperipheral.info/ (3 seperate downloads). Modpack is here http://www.technicpa...ack.588534/mods

I dont know why its tile_blockblahblah instead of capacitor_bank. But having wrong information may come from the peripheralwrap itself, since its named "tile_blockcapablahlblah_nameX" and X indicates the number of the bank in the whole array with capabanks ( so it starts with 1 and ends with 38 in my example )

Hmm, can you check all of the peripheral names for me? Are you getting different types assigned to everything or just capacitor banks? The ones on my world are "powered_tile" (applies to both TE Energy Cells and Mekanism Energy Cubes, possibly others as well), and "BigReactors_Turbine".

Also, are you saying that if you have a 38 block capacitor bank, it's assigning a different network name to every block in the capacitor bank? That's very strange, especially since you have the exact same versions of Computercraft, OpenPI, and EnderIO as I do.

Oh, and I can't believe I didn't ask this earlier: Why does your capacitor bank have an Input/Output screen on it?

Thermal Expansion Cells give "tile_thermalexpansion_cell_[category]_name" ( e.g. "tile_thermalexpansion_cell_basic_name" for leadstone cell )
Mekanism Cubes give "[category] Energy Cube" ( e.g. "Elite Energy Cube" for elite energy cube )

Capacitor banks do this now if you shift-rightclick them empty handed.

#13 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 02 April 2015 - 09:42 PM

View PostKaidenyo, on 02 April 2015 - 05:50 PM, said:

Thermal Expansion Cells give "tile_thermalexpansion_cell_[category]_name" ( e.g. "tile_thermalexpansion_cell_basic_name" for leadstone cell )
Mekanism Cubes give "[category] Energy Cube" ( e.g. "Elite Energy Cube" for elite energy cube )

Capacitor banks do this now if you shift-rightclick them empty handed.

Yours sounds like a much more reliable naming system, I wish mine worked like that. I've asked in a few places and nobody seems to have any idea why/how this could be happening. But I'll keep searching.

Update 1:

AHA! I figured it out! I removed three of the mods you didn't have on your server, immibis' peripherals, OpenCCSensors and Computronics and that fixed it. Now I just need to add them back in 1 by 1 to find out which mod it is that messes it up.

Update 2:

Yep, I found it. Look at this inside Computronics config file:

computercraft {

    ##########################################################################################################
    # multiperipheral
    #--------------------------------------------------------------------------------------------------------#
    # If all of these options are set to true, Computronics will fix almost every conflict with multiple mods adding peripherals to the same block
    ##########################################################################################################

    multiperipheral {
        # Set this to true to fix multiple mods adding peripherals to the same block not working [default: true]
        B:allMultiPeripherals=true

        # If this is true, the Computronics MultiPeripheral system will almost always be the one recognized by ComputerCraft [default: true]
        B:alwaysFirstPeripheral=true

        # Set this to false to disable MultiPeripheral compatibility with OpenPeripheral peripherals [default: true]
        B:openMultiPeripheral=true
    }

}

It looks like if I just set B:openMultiPeripheral=false it should fix the issue.

Update 3:

Nope, none of the config setting made a difference, you have to remove computronics entirely in order for the names to go back to normal. I'll just have to mark the script as incompatible with Computronics.

I'm currently working on rewriting the code to properly get the new types. It's a fair amount more difficult than before since there are more valid names. I could list all of them but I'd rather sort them by class which will require some pattern matching.

Edited by Umaroth, 02 April 2015 - 11:04 PM.


#14 Kaidenyo

  • Members
  • 11 posts

Posted 03 April 2015 - 07:33 AM

Man, I gave you some work ... but glad you could figure it out

#15 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 04 April 2015 - 04:10 AM

View PostKaidenyo, on 03 April 2015 - 07:33 AM, said:

Man, I gave you some work ... but glad you could figure it out

Well, I got it working with the new names, but now I'm having the same problem you had. It only reads from the block it's connected to with the Capacitor Banks

#16 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 06 April 2015 - 12:57 AM

Update: I spoke to the dev of Computronics and he informed me that the reason the script can't get the correct values for Capacitor Banks is because OpenPeripherals doesn't have support for the way Capacitor Banks handle RF values but Computronics does, which explains why it worked for me in the first place.

So what this means is that I'll have to require Computronics for the script to work properly with Capacitor Banks. I can code support for both Computronics and OpenPeripheral names but if anyone has OpenPeripherals without Computronics they won't be able to get the correct values from Capacitor Banks. In that event I'll put a variable in the code for someone to manually specify how many Capacitor Bank blocks are in their multiblock structure, which comes with obvious problems, but it's the best they can get without Computronics.

I'll work on the rewrite tonight and should have it done within a few hours.

#17 Umaroth

  • Members
  • 12 posts
  • LocationUSA

Posted 06 April 2015 - 05:09 AM

Alright, I'm done, the rewrite is complete and I did a few testing rounds. I updated the Changelog and program Pastebin uploads and I updated the main post (still need to take new pictures). Everything should be up to date and operational. Please let me know if you encounter any further problems or have any suggestions.

Edited by Umaroth, 06 April 2015 - 05:10 AM.


#18 isaokirito

  • New Members
  • 2 posts

Posted 08 April 2015 - 02:37 AM

I typed pastebin get cA2TNNdH PowerMonitor into my computer and it says No Such program.

#19 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 08 April 2015 - 09:22 AM

the http api is disabled, if you are on a server, ask the owner to, if you are in singleplayer, change the config

#20 pugsx

  • New Members
  • 2 posts

Posted 12 April 2015 - 02:43 PM

Loving the script so far but cant figure the connection between the computer and the reactor (noob here)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users