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

I need some help!

Started by JBoyJr, 24 December 2013 - 05:43 PM
JBoyJr #1
Posted 24 December 2013 - 06:43 PM
I would like to make a lectern display like on the video [media]http://www.youtube.com/watch?v=tZe9-D4h-Rg[/media]
If anyone could help me like give me code that would be wonderfull thanks!

It is first shown at 3:26

and also how it shows up on the monitor if anyone could help me with that

Like at 37:21 when you see it display on the monitor from the lecturn display thing
Abahu #2
Posted 25 December 2013 - 02:53 AM
It's not too complicated, just time consuming. However, the best thing to do is to learn the basics and go from there. First, learn Lua. Learn what you have in your toolbelt and then learn what work-arounds you have. Then you need to actually know what you're trying to make. For this basic display, you'll need to do this: Read keystrokes to know what slide you're on and send to a monitor via RedNet what you want the slide to say, and then print out that slide. If you have a specific question on how to achieve one of these tasks, then you ask in AaP. You probably shouldn't ask for an entire program.

With that in mind: DFTBA!
awsmazinggenius #3
Posted 25 December 2013 - 09:44 AM
Or you can use the wired cables. Here is a template for creation:

rednet.open("top") --# For you, you should stick with rednet until you're a bit more advanced.
while true do
  _, k = os.pullEvent("key")
  if keys.getName(k) == "left" or keys.getName(k) == "w" then
	rednet.broadcast("lectern.previousSlide")
  elseif keys.getName(k) == "right" or keys.getName(k) == "d" then
	rednet.broadcast("lectern.nextSlide")
  end
end
That's the server, you'd just make a simple client to act upon these commands.
Edited on 25 December 2013 - 08:45 AM
JBoyJr #4
Posted 25 December 2013 - 12:21 PM
Or you can use the wired cables. Here is a template for creation:

rednet.open("top") --# For you, you should stick with rednet until you're a bit more advanced.
while true do
  _, k = os.pullEvent("key")
  if keys.getName(k) == "left" or keys.getName(k) == "w" then
	rednet.broadcast("lectern.previousSlide")
  elseif keys.getName(k) == "right" or keys.getName(k) == "d" then
	rednet.broadcast("lectern.nextSlide")
  end
end
That's the server, you'd just make a simple client to act upon these commands.
Thanks awsmazinggenius however will I be able to controll it from a computer?
TheOddByte #5
Posted 25 December 2013 - 01:54 PM
Well if you decide to go with wired modems then here's how you can do that

local monitors = {}
--# Getting all the monitors attached
for _, name in ipairs(peripheral.getNames()) do
	if peripheral.getType( name ) == "monitor" then
		local nMon = {}
		nMon.name = name
		table.insert(monitors, nMon)
	end
end

--# Wrapping the monitors
local w, h = term.getSize()
for i = 1,#monitors do
	monitors[i].name = peripheral.wrap(monitors[i].name)
	monitors[i]["name"].setTextScale(0.5)
	for scale = 1, 5, 0.5 do
		monitors[i]["name"].setTextScale( scale )
		local mW, mH = monitors[i]["name"].getSize()
		if mW < w or mH < h then
			monitors[i]["name"].setTextScale( scale - 0.5 )
			break
		end
	end
end

--# Here's a function that writes to all the montiors
local function monWrite( text )
	for i = 1,#monitors do
		monitors[i].name.write( text )
	end
end

--# This is the main part of the program, I think you can handle the rest here ;-)
local slide = 1
while true do

	-- Put the drawing code here

	local _, p1 = os.pullEvent()
	if p1 == keys.left then
		if slide > 1 then
			slide = slide - 1
		end

	elseif p1 == keys.right then
		-- Change to the next slide here
	end
end
Edited on 25 December 2013 - 12:55 PM
JBoyJr #6
Posted 25 December 2013 - 02:00 PM
thank you