This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MrLethalBlood's profile picture

Pneumaticcraft script

Started by MrLethalBlood, 21 May 2016 - 07:07 AM
MrLethalBlood #1
Posted 21 May 2016 - 09:07 AM
Hey guys,

I got a question, i am a noob with cc, normally what i do is copy a code and then keep reading it and googling to understand it.

What I want is a script to get the pressure from my tube's and if the pressure is higher then 4 it must send a redstone signal to release air.

I was trying it a bit myself but I never know how to start a code and then actualy make a working one xD

like my level is a simple door lock….

anyways, i hope one of you could help me making one?

Thanks guys!

https://gyazo.com/d4f210ece191764314454175c62ad2aa this is what I have so far, i tested the p.getpressure in lua and it works, but I have no idea how to make a script around it,.
The_Cat #2
Posted 22 May 2016 - 02:05 AM
Hi there,
I have no experience with pneumaticcraft, but these seems basic enough.
So you have the basics which is good all you need to do now is had a rs.setOutput("side", true) (which you have commented out)
dir can also be "front", "left", "right", "top", "bottom" and "back". (I find this easier)
Here's what I would do:

p = peripheral.wrap("back")
while true do --# Run forever so it doesn't just execute once
	if p.getPressure("north") > 4 then --# Looks like you know what this does
		redstone.setOutput("left", true) --# So if the statement is true we want to set an output to true, so you can connect the redstone with the vent valve
	else --# If it is not > then 4
		redstone.setOutput("left", false) --# Set the left side to false so it stops venting
	end
	os.sleep(0.5) --# Sleep for a set time as if you don't the program will crash (you can change this to anything you want) if you remove it you will get a wielding error
end
Hope this helps :)/>
Edited on 22 May 2016 - 12:06 AM
MrLethalBlood #3
Posted 22 May 2016 - 07:23 AM
Hey,
I am gonna test it in a bit, it looks like I was on the right path but missing some knowledge haha.
Thanks for the help and time :D/>