[LUA] How to get multiple booleans values to stay on a state file(better explanation inside)
#1
Posted 06 September 2012 - 12:56 AM
link to code : http://pastebin.com/8HS4skup
#2
Posted 06 September 2012 - 01:20 AM
#3
Posted 06 September 2012 - 01:41 AM
Pharap, on 06 September 2012 - 01:20 AM, said:
Do you have any Idea how I could improve that part of the code or any other way I could do this? I have looked everywhere and that was the only thing I could find.
#4
Posted 06 September 2012 - 02:08 AM
n1ghtk1ng, on 06 September 2012 - 01:41 AM, said:
Pharap, on 06 September 2012 - 01:20 AM, said:
Do you have any Idea how I could improve that part of the code or any other way I could do this? I have looked everywhere and that was the only thing I could find.
well, redset should be a program in your computer, if it isn't there, you should be getting errors.
Well your major flaw is that when the output is being set, it's being set to a single colour, thus it's only sending that one colour, not all the colours needed. To fix that you'd need a variable storing the current colour output and you'd need to amend it with every switch on/off of a machine. If you have no clue how to do that, I can walk you through it, but solving the problem from what I've just said should be simple enough if you are proficient with the colours api.
#5
Posted 06 September 2012 - 02:36 AM
Pharap, on 06 September 2012 - 02:08 AM, said:
n1ghtk1ng, on 06 September 2012 - 01:41 AM, said:
Pharap, on 06 September 2012 - 01:20 AM, said:
Do you have any Idea how I could improve that part of the code or any other way I could do this? I have looked everywhere and that was the only thing I could find.
well, redset should be a program in your computer, if it isn't there, you should be getting errors.
Well your major flaw is that when the output is being set, it's being set to a single colour, thus it's only sending that one colour, not all the colours needed. To fix that you'd need a variable storing the current colour output and you'd need to amend it with every switch on/off of a machine. If you have no clue how to do that, I can walk you through it, but solving the problem from what I've just said should be simple enough if you are proficient with the colours api.
And sorry for being so ignorant, This is my first programming language(at age 13), and I've only being programming ~2 weeks.
Edit: This is my first time using most of these API'S (fs, colors, shell)
#6
Posted 06 September 2012 - 02:52 AM
n1ghtk1ng, on 06 September 2012 - 02:36 AM, said:
Pharap, on 06 September 2012 - 02:08 AM, said:
n1ghtk1ng, on 06 September 2012 - 01:41 AM, said:
Pharap, on 06 September 2012 - 01:20 AM, said:
Do you have any Idea how I could improve that part of the code or any other way I could do this? I have looked everywhere and that was the only thing I could find.
well, redset should be a program in your computer, if it isn't there, you should be getting errors.
Well your major flaw is that when the output is being set, it's being set to a single colour, thus it's only sending that one colour, not all the colours needed. To fix that you'd need a variable storing the current colour output and you'd need to amend it with every switch on/off of a machine. If you have no clue how to do that, I can walk you through it, but solving the problem from what I've just said should be simple enough if you are proficient with the colours api.
And sorry for being so ignorant, This is my first programming language(at age 13), and I've only being programming ~2 weeks.
Edit: This is my first time using most of these API'S (fs, colors, shell)
It's ok, just be sure to mention if you've copied someone elses code, otherwise people will assume you've written it and thus know what everything in it does.
And if you don't they will figure out by about the second question when you don't know what one of the lines does. It's easiest to just mention from the start so people know.
Anyway, in regards to fixing your problem:
In CC, colours are stored as numbers, thus they are a fixed value, even combined colours, so you can store the output to a single variable.
Firstly, set that variable at the top, something like
local OP = 0 --0 is no colour output
Then what you want to do is in each section of code changing the bundled output, before changing anything the output, set OP to the value of the current bundled output (so OP = rs.getBundledOutput()) then when you go to set the output, where the output is currently 'colours.white' or 'colours.yellow' or something, set it instead to output OS and the new colour, so for the white output:
rs.setBundledOutput(side, colours.combine(OP, colours.white))
in the case of setting the machine off, use colours.subtract instead, so:
rs.setBundledOutput(side, colours.subtract(OP, colours.white))
I'm sure you can fix it from that, but again, if need be, I can upload a paste of the reworked code.
Also if you don't have a redset program on your computer, you can delete all those lines regarding the running of redset.
I also remember my first few times programming, it's been nearly a year since then, things get a lot easier.
#7
Posted 06 September 2012 - 11:56 AM
I did what you told me to (well how I interpreted it) But when I enter lets say enginecoolant, nothing happens.)
Also is there any other way I could improve my code?
Thanks
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











