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?
Code for detecting number of redstone inputs.
Startup code
Infinite loop waiting for redston update.
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?
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