128 posts
Location
Poland
Posted 19 November 2012 - 08:18 AM
Hey, I'm writed an code an it don't work can you help me?
Error: st:2: attempt to call nil
code:
mon = peripheral.wrap("back")
rin = rs.getBoundledInput( "front" )
mon.setTextScale(2)
while true do
if colors.test( rin, colors.lime) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 100%")
elseif colors.test( rin, colors.yellow) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 75%")
elseif colors.test( rin, colors.lightBlue) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 50%")
elseif colors.test( rin, colors.magneta) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 25%")
else
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 0%")
end
if colors.test( rin, colors.white) == true then
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: Wlaczone")
else
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: Wylaczone")
end
sleep(0)
end
I'm from poland and this code have Polish language :)/>/>
1054 posts
Posted 19 November 2012 - 08:19 AM
Line 2 should be:
rin = rs.getBundledInput( "front" )
instead of:
rin = rs.getBoundledInput( "front" )
The rest of the code should work (only took a quick glance though). :)/>/>
1688 posts
Location
'MURICA
Posted 19 November 2012 - 08:20 AM
You misspelled "bundledInput" on line 2. It should be
rin = rs.getBundledInput( "front" )
EDIT: ffsfnsnSN
128 posts
Location
Poland
Posted 19 November 2012 - 08:20 AM
Is like this :/
Edit: It's writing new error
bios:206: [string "st"]:2: unexpected symbol
Working thanks :)/>/>
Edited on 19 November 2012 - 07:23 AM
1054 posts
Posted 19 November 2012 - 08:23 AM
Is like this :/
Edit: It's writing new error
bios:206: [string "st"]:2: unexpected symbol
Please post full code again. We can't know what went wrong like this. You probably put a '=', '(' or ')' wrong somewhere.Edit: ok, glad it works. :)/>/>
128 posts
Location
Poland
Posted 19 November 2012 - 08:37 AM
But the update system don't works can you help me? :)/>/>
Giving full code again:
mon = peripheral.wrap("back")
rin = rs.getBundledInput( "front" )
mon.setTextScale(2)
while true do
if colors.test( rin, colors.lime) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 100%")
elseif colors.test( rin, colors.yellow) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 75%")
elseif colors.test( rin, colors.lightBlue) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 50%")
elseif colors.test( rin, colors.magneta) == true then
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 25%")
else
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Zasilanie: 0%")
end
if colors.test( rin, colors.white) == true then
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: Wlaczone")
else
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: Wylaczone")
end
sleep(0,5)
end
1054 posts
Posted 19 November 2012 - 08:52 AM
Could you clarify what you mean with ' didn't work '? Anyway, there is one mistake at the one but last line:
sleep(0,5)
should be:
sleep(0.5)
The comma separates the parameters and only the first one is being used, so you'd sleep '0' seconds instead of '0.5'. Note that sleep(0) actually sleeps like 0.05 seconds or something.
1688 posts
Location
'MURICA
Posted 19 November 2012 - 08:53 AM
Second-to-last line:
sleep(0,5)
should be
sleep(0.5)
EDIT: it keeps happening
128 posts
Location
Poland
Posted 19 November 2012 - 08:56 AM
Don't working
For example:
I'm run the program and quarry is off and when I'm turning this on it's writing querry is off and i have to restart program to update this
Please help (again :)/>/>)
1054 posts
Posted 19 November 2012 - 08:58 AM
Oh, move line 2 in the while loop. So this line:
rin = rs.getBundledInput( "front" )
should go right under
while true do
128 posts
Location
Poland
Posted 19 November 2012 - 09:00 AM
Very very mouch thanks working! :)/>/>
1054 posts
Posted 19 November 2012 - 09:04 AM
Good. :D/>/> Just to explain it a bit. When you do that line, rin becomes the current status of the bundled cable (a numerical value), so you'd want to update that in every iteration of the loop. Now you only updated it once at the beginning of the program. :D/>/>
Off topic:
Second-to-last line:
sleep(0,5)
should be
sleep(0.5)
EDIT: it keeps happening
:D/>/> I am 'studying' right now, which means that I'm behind my laptop desperately in search of a distraction. :)/>/>
128 posts
Location
Poland
Posted 19 November 2012 - 09:33 AM
Good. :D/>/> Just to explain it a bit. When you do that line, rin becomes the current status of the bundled cable (a numerical value), so you'd want to update that in every iteration of the loop. Now you only updated it once at the beginning of the program. :D/>/>
Off topic:
Second-to-last line:
sleep(0,5)
should be
sleep(0.5)
EDIT: it keeps happening
:D/>/> I am 'studying' right now, which means that I'm behind my laptop desperately in search of a distraction. :)/>/>
It's new problem it's writing bit:40: double expected, got nil (It's happends only when "Zasilanie" - Power Level is changing)
1054 posts
Posted 19 November 2012 - 09:39 AM
Change this line:
elseif colors.test( rin, colors.magneta) == true then
into this:
elseif colors.test( rin, colors.magenta) == true then
You spelled magenta wrong. :D/>/> So you passed a nil value to colors.test() which later on probably did a shift operation with it using the bit api, which led to that error. :)/>/>
128 posts
Location
Poland
Posted 19 November 2012 - 09:51 AM
Thanks :)/>/>