3 posts
Posted 25 September 2015 - 08:57 PM
Hello, I'm pretty new to ComputerCraft, but I'm familiar with C++ and Lua doesn't seem that different, so I'm trying to learn.
I'm looking for a program that graphs the input from a redstone signal into a computer over around a minute, and displays it on a monitor.
I would like a sample program, not individual instructions, if anyone can write one up real quick.
Thanks!
8543 posts
Posted 26 September 2015 - 12:51 AM
Moved to General.
818 posts
Location
Wherever you want me to be
Posted 26 September 2015 - 02:34 AM
a little offtopic, but if you want to learn lua i recommend direwolf20's computercraft tutorials.
1583 posts
Location
Germany
Posted 27 September 2015 - 01:14 AM
a little offtopic, but if you want to learn lua i recommend direwolf20's computercraft tutorials.
I guess it would be better to learn the actual language first instead of jumping right into the APIs. Atleast the syntax because the OP knows another language already. If the OP has a basic understanding of lua he could/should begin with CC. Else you'll get more confused than "needed".
3057 posts
Location
United States of America
Posted 27 September 2015 - 01:47 AM
Well, this seems like a fun little piece of code to write…
local data = {}
for k, v in pairs( rs.getSides() ) do
data[ v ] = {}
end
for i = 1, 60 do
for side, tbl in pairs( data ) do
tbl[ i ] = rs.getAnalogInput( side )
end
sleep( 1 )
end
--#wohoo, we've got the data! Now to graph it...
local cSides = {
right = colors.green,
left = colors.yellow,
top = colors.blue,
bottom = colors.red,
front = colors.purple,
back = colors.white,
}
local mon = peripheral.find( "monitor", function( name, handle ) return handle.isColor() end )
if not mon then
error( "No advanced monitors found!", 0 )
end
mon.setBackgroundColor( colors.black )
mon.clear()
for side, tbl in pairs( data ) do
mon.setBackgroundColor( cSides[ side ] )
for i = 1, 60 do
mon.setCursorPos( i, data[ i ] )
mon.write( " " )
end
end
Edited on 26 September 2015 - 11:47 PM