Jump to content




Monitor Storage tanks lua script


  • You cannot reply to this topic
20 replies to this topic

#21 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 19 September 2014 - 02:10 PM

View Posticeman11a, on 19 September 2014 - 11:00 AM, said:

(I can't find any thing related to a vanilla squid ink)

Ink that is available in vanilla - that is to say, unmodified - versions of MineCraft. That is to say, OpenPeripheral doesn't add it because it's already there. This stuff. You get it by butchering squid.

Anyway. Regarding reading energy levels, let's recap:

1) Stick a computer next to a cell/tank/whatever, run openp/docs <side>.

2) If a function for getting storage levels of energy or whatever you want is listed: Great, use that. (Such functions are recognisable by their names.)

3) As has been established, you're unlikely to find such a function for a given storage block with your current installation.

If a suitable function isn't listed, then you cannot get the information you want while treating the target block as a peripheral, while using your current install. Period. Full stop. To try is to shove the proverbial square peg against the round hole. The only way to change that is to change your entire MineCraft set up - MC 1.6.4 supports the stable mod builds which actually have the functionality you want, 1.7.10 currently does not. The cutting edge is the bleeding edge, as they say.

So! With all that in mind, let's forget about using OpenPeripheral to get energy levels from whatever it is you're trying to read from under 1.7.10 for now and try using a comparator instead.

The comparator has lots of handy functions, but that which we're interested in is the one which sends out redstone signals of strength according to the volume stored in a given storage block. ComputerCraft, of course, has its own API for dealing with redstone. rs.getAnalogInput() is, of course, the function we're interested in for the purposes of reading a variable signal strength.

Stick a comparator between your computer and the block you want to try to "read". The side with the two prongs should be facing the target, the side with the single prong should face the computer. Set it to "comparator" mode (by right-clicking it until the single prong goes dark).

Open the Lua command prompt on your computer and enter:

rs.getAnalogInput("whatEverSideTheComparatorIsOn")

You'll get a number between 0 and 15. If the number is 0, and the target block has a decent amount of "stuff" in it, you can safely assume the mod author didn't rig his block to work with comparators. If you get something non-zero, well done, you can read levels from that block.

If you can't use comparators/redstone signals with your target blocks, and the peripheral path is out, then there really aren't any other options concerning ComputerCraft with those software versions. Try using different mods instead - make some BuildCraft gates, for example.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users