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

Problems!?!?!

Started by S0N_G0KU_Z, 12 April 2013 - 09:45 AM
S0N_G0KU_Z #1
Posted 12 April 2013 - 11:45 AM

m = wrap("monitor")
term.redirect(m)

function colorScreen(color)
  for a = 0,59 do
	for b = 0,19 do
	  paintutils.drawPixel(a,b,color)
	end
  end
end
function setScreen(color)
  local s = {}
  for i =1,51 do
	s[i] = {}
	for j =1,19 do
	  s[i][j] = color
	end
  end
  return s
end
shell.run("clear")
local screen = setScreen(16)
local color = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
local i = 1
while true do
  paintutils.drawPixel(1,1,color[i])
  event,value,x,y = os.pullEvent()
  if event == "mouse_click" or event == "mouse_drag" then
	if value == 1 then
	  screen[x][y] = i
	  paintutils.drawPixel(x,y,color[i])
	elseif value == 2 then
	  i = screen[x][y]
	end
  elseif event == "mouse_scroll" then
	i = i + value
	if i < 1 then i = 1
	elseif i > 16 then i = 16 end
  elseif event == "key" then
	if value == 46 then -- Lettre C
		colorScreen(32768)
		screen = setScreen(16)
	elseif value == 47 then -- Lettre V
		colorScreen(color[i])
		screen = setScreen(i)  shestartup

	elseif value == 20 then --Lettre T
	  break
	end
  end
end
colorScreen(32768)
shell.run("clear")

HELP I DONT UNDERTSAND what i did wrong

[Tasteful editing, and code tags added -Cranium]
Edited on 12 April 2013 - 03:02 PM
ds84182 #2
Posted 12 April 2013 - 12:04 PM
*ahem* First of all, you put this in API's And Utilities, that wont give you much of help. Second, you never told us what errors you are getting. But you tried, and that's one thing that counts when getting help with ComputerCraft. Moderators, can you please move this to Ask a pro?
Lyqyd #3
Posted 12 April 2013 - 04:48 PM
Report. Don't reply, just report. Let us take care of the corrections.

Moved to Ask a Pro.
PixelToast #4
Posted 12 April 2013 - 04:59 PM
use
 tags
what was the error?
anyway, replace monitor (on top) with whatever side the monitor is (top,bottom,left,right,front,back)
S0N_G0KU_Z #5
Posted 13 April 2013 - 10:05 AM
im getting a startup:1: atempt tp call nil
TehSomeLuigi #6
Posted 13 April 2013 - 10:09 AM
m = wrap("monitor")


should be

m = peripheral.wrap("top")

wrap is a method of the peripheral API which you pass the side to get a peripheral handle.
S0N_G0KU_Z #7
Posted 13 April 2013 - 10:14 AM
now im getting term:16: Ivaliad redirect objetc
S0N_G0KU_Z #8
Posted 13 April 2013 - 10:19 AM
im not getting an error but my picture wont show on the monitor

mon = peripheral.wrap("right")
logo = paintutils.loadImage(".logo")
electrodude512 #9
Posted 13 April 2013 - 10:26 AM
You wrapped your monitor, and you loaded your image, but you never actually put the image on the monitor. "paintutils.drawImage(logo,1,1)" will draw your image to the computer's screen, but I'm not sure how to redirect that to your monitor.

electroudude
SadKingBilly #10
Posted 13 April 2013 - 10:29 AM
You have to do term.redirect(mon) in order to force your terminal's output to the wrapped monitor. Also, you loaded the image object but didn't actually draw it on the screen. Try paintutils.drawImage(paintutils.loadImage("logo"), 1, 1).
LBPHacker #11
Posted 13 April 2013 - 10:34 AM
now im getting term:16: Ivaliad redirect objetc
I'm pretty sure you can't have a peripheral called just "monitor", even with peripheral cables. Check the name.
TheOddByte #12
Posted 13 April 2013 - 10:51 AM
As they have said: You have loaded the image but you haven't drawn it..
So I guess this is the code you want:

mon = peripheral.wrap("right")

--Here you load the image as logo
logo = paintutils.loadImage(".logo")

--And here you draw it on the monitor
mon.drawImage(logo)

Also.. This should have been posted in ask a pro
S0N_G0KU_Z #13
Posted 13 April 2013 - 11:00 AM
ok im getting paintutils:92: attempt to get lenght of nil
Lyqyd #14
Posted 13 April 2013 - 11:05 AM
Questions need to be asked in the Ask a Pro section.

Moved to Ask a Pro.
S0N_G0KU_Z #15
Posted 13 April 2013 - 11:11 AM
–By:S0N_G0KU_Z
mon = peripheral.wrap("right")
print = paintutils.loadImage(".logo")
paintutils.drawImage("logo")

I dont understand what is wrong im getting
paintutils:94: attempt to get length of nil
Sammich Lord #16
Posted 13 April 2013 - 11:13 AM
You posted multiple threads about the same problem.
Here is how you should do it:

local mon = peripheral.wrap("right")
local img = paintutils.loadImage(".logo")
term.redirect(mon)
paintutils.drawImage(img, 1, 1)
term.restore()
Lyqyd #17
Posted 13 April 2013 - 12:30 PM
These all look like questions about the same code to me. Threads merged.
S0N_G0KU_Z #18
Posted 13 April 2013 - 01:10 PM
ty all