Tank automation with xy-craft and CS

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Nebuchadnezzar

New Member
Jul 29, 2019
17
0
0
I am trying to create a system to meassure how much liquid I have in my tanks. The progress is going fine as one can see in the images below. Bear in mind I have experience with programming, but not with lua. The idea is to have a global program tht can be attatched to a tank of any size and still be able to read the level.
In order to do so, one have to manually read in the tank dimensions. Is there any way to save this information on the disk?
For each reboot one has to manually type in this information which is cumbersome. I do not need to store this information globaly, it is just for one computer =) I know I can use chunk loaders, but again having to chunk load all your tanks is also cumbersome.

Any tips or suggestions for the setup and code is welcome (I know there exist tank meassurements for railcraft tanks, but it is a fun project to learn some programming).
Again is there any way to save variables on the disk through a reboot, using input only?

tanksetup.png

tanksetup.png

tanksetup1.png

tanksetup1.png

tanksetup2.png

tanksetup2.png

Code for detecting number of redstone inputs.

Code:
bCableBack = rs.getBundledInput("back")
 
  function Antall(bit)
    if bit <= 0 then
       return 0
    else
    Nr = math.floor(math.log(bit)/math.log(2)) + 1
       return Nr
    end
  end
 
Nr = Antall(bCableBack)

Startup code

Code:
    term.clear()
    term.setCursorPos(1,1)
   
    print("=================================")
    print("                                ")
    print("      Setup for tanks!          ")
    print("                                ")
    print("=================================")
    print(" ")
   
    h = 0
    w = 0
    l = 0
   
    write("Tankname: ")
    name = read()
   
    print(" ")
    print("Write in the tank dimensions ")
    print(" ")
    write("height: ")
    temp = read()
      if temp ~= "" then
          h = temp
      end
   
    write("width: ")
    temp = read()
      if temp ~= "" then
        w = temp
      end
   
    write("length: ")
    temp = read()
      if temp ~= "" then
          l =  temp
      end
   
    Volume = 16000*(w-2)*(l-2)*(h-2)
    Increment = 100/(h-2)
   
    print(" ")
    print("Maximum Volume: ", Volume)
   
    shell.run("tanks")
   
    Percent2 = Nr*Increment
    Percent1 = (Nr-1)*Increment
   
    print(" ")
   
      if bCableBack == 0 then
        print("The Tank is 0% full")
        print("Exactly: 0 Buckets ")
      elseif Nr == h - 2 then
        print("The Tank is 100% full")
        print("Exactly: ",Volume/1000," Buckets")
      else
        Bucket = Volume*(Percent1+Percent2)/(2*10^5)
        print(Percent1, "% <= Tank fullness < ", Percent2,"%")
        print("Roughly:",Bucket, " Buckets")
      end
   
    shell.run("Display")


Infinite loop waiting for redston update.

Code:
while true do
  local event = os.pullEvent("redstone")
 
term.clear()
term.setCursorPos(1,1)
 
print("=================================")
print("                                 ")
print("       Setup for tanks!          ")
print("                                 ")
print("=================================")
print(" ")
print("Tankname: ", name)
print(" ")
print("height: ", h)
print("width: ", w)
print("length: ", l)
print(" ")
print("The maximum Volume is: ", Volume)
 
shell.run("tanks")
Percent2 = Nr*Increment
Percent1 = (Nr-1)*Increment
 
print(" ")
 
  if bCableBack == 0 then
    print("The Tank is 0% full")
    print("Exactly: 0 Buckets")
  elseif Nr == h - 2 then
    print("The Tank is 100% full")
    print("Exactly: ",Volume/1000, " Buckets")
  else
    print(Percent1, "% <= Tank fullness < ",Percent2,"%")
    Bucket = Volume*(Percent1+Percent2)/(2*10^5)
    print("Roughly: ", Bucket, " Buckets")
  end
 
end
 

Attachments

  • tanksetup2.png
    tanksetup2.png
    11.1 KB · Views: 57
  • tanksetup1.png
    tanksetup1.png
    9.6 KB · Views: 59
  • tanksetup.png
    tanksetup.png
    202.6 KB · Views: 50
  • Like
Reactions: Exe19

Adonis0

New Member
Jul 29, 2019
1,800
0
0
If this is for the coding experience, go for it
But may I point you towards an easier mod to use for detecting liquid levels? (Or energy levels on storage, and heat levels on nuclear reactors)

Nuclear control has an amazing monitoring system, get a liquid detection kit, use it on the tank, you get a liquid location card, put that in a information panel, and volia, you have a view of your liquid

Put range upgrades into information panels if it's too far away from the tank, add information panel extenders in a rectangular or square patten with the original information panel as part of it, and you get a bigger screen

Heck there's even colour upgrades for the screen.
 

Nebuchadnezzar

New Member
Jul 29, 2019
17
0
0
Indeed! The Liquid Sensor Kit is a very tempting alternative, but they do not work with XY-tanks?
Also they are exellent for viewing liquid from one tank. The problems I had was on how to automate things
(do X when the tanklevel reaches Y) and how to combine monitors =)
Also coding is fun ^^
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0

Adonis0

New Member
Jul 29, 2019
1,800
0
0
Indeed! The Liquid Sensor Kit is a very tempting alternative, but they do not work with XY-tanks?
Also they are exellent for viewing liquid from one tank. The problems I had was on how to automate things
(do X when the tanklevel reaches Y) and how to combine monitors =)
Also coding is fun ^^

Ahh, I see what you mean, in that case yes I see the justification for using the coding

Coding is powerful.. but I don't have the patience to work out the bugs for it to be worth it for me, so I tend to try and find ways around it

The automation can be crudely done with the mechanics of the xycraft tanks, valves only output liquid if the tank level is high enough to cover them

for instance with my tanks I activate a wooden pipe and void pipe all the excess when it's full, how? I put a valve on the roof and set a gate to always run, I did it that way because gates haven't always worked reliably for me, but this seems to work how I expect.