cameron2134 Posted March 30, 2013 Posted March 30, 2013 Hey, I'm pretty new to ComputerCraft, just started playing around with it today. I've made a couple simple programs such as a password protected door, and a computer that controls lights, however what I have been trying for the past hour or so is a computer to control all the machines in my factory. It's pretty much done - I just can't figure out how to "add up" the bundled cable values, for example, I have 3 output cables: white, red, and orange. I can turn white on, but when I turn red on, white turns off, because the value changes to 16385 instead of 16386 for both white and red. I know what I have to do, make it so that if white cable is on, it adds one to the red cable when I turn it on, and if white and red are on, it adds 16386 to the orange cable, so all 3 turn on. Only thing is I have no idea how to do this in Lua. I think it might involve using variables, although I am still not sure. If you could help it would be much appreciated, so close to finishing this and now I'm stumped right at the end Code: http://pastebin.com/iAwFCbyJ The "state" variable is when I tried to use variables to add them but I could not get it to work.
Maxis010 Posted March 30, 2013 Posted March 30, 2013 Declare state as 0 (All off) then have a function that takes the variables state, cable and set State is the state variable Cable is the cable you want to change Set is it's new state, IE On/Off First the function parses state, so it finds out what is on and off already Then it finds out what cable needs to change and what to Makes that change over And returns state That is how I would handle it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now