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

Question - Display on Monitor at startup

Started by placlu, 28 June 2012 - 05:48 PM
placlu #1
Posted 28 June 2012 - 07:48 PM
Hello, so we recently installed tekkit on our server and I was messing around with this.
ATM, I have it set up every time I want a message (Startup message to be exact) I have to type "Monitor Left Startup", I was wondering if at all possible on reboot (or chunk re-entry) if it could automatically display it on the monitor.

Sorry if this is an easy question/has been answered before, but I've messed around and googled quite a bit with no prevail.

Thanks.
MysticT #2
Posted 28 June 2012 - 08:00 PM
There's two options:
1) Put this at the top of the startup program:

local monitorSide = "left" -- the side the monitor is on

if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  term.redirect(peripheral.wrap(monitorSide))
else
  print("No monitor found")
  return
end

-- Your code here

term.restore()
2) Save your program with other name, and then put this in the startup file:

shell.run("monitor", "<MonitorSide>", "<YourProgramName>")
Lyqyd #3
Posted 28 June 2012 - 08:00 PM
Yep. Just put this in your startup file for that computer:


term.redirect(peripheral.wrap("left"))
--print whatever
term.restore()
placlu #4
Posted 29 June 2012 - 02:33 AM
alright brilliant :)/>/>

one more question just because you seem to know everything about this :P/>/>
The startup program is essentially just a splash screen like "Welcome back home Placlu, please enter passcode"
and to open my door, you need to right click the computer, type in the program "door" and then the password.

How would I go about having it so I right click the computer and just type in the password to open the door, otherwise anyone can just do "edit door" and see the password. Not that anybody on the server would, but still defeats the whole purpose of it haha.

But thankyou, everything works awesomely now B)/>/>
MysticT #5
Posted 29 June 2012 - 02:52 AM
You can either add the login/password code to the startup file, or run it from it.
If you want to add it to the startup, just copy the code to the end.
To run it from the startup, but keep it as a separate file, add:

shell.run("<ProgramName>")
at the end of the startup file.
placlu #6
Posted 29 June 2012 - 03:14 AM
You're Awesome :P/>/>

Thankyou so very much :)/>/>
Lazymuffin #7
Posted 29 June 2012 - 04:22 AM
I have an additional question.
I'm trying to make a facility with multiple computers, each will control monitors displaying different information depending on redstone input changes.

is there a way to designate which one should run which program on startup? I'll have to change to single display otherwise.
Lyqyd #8
Posted 29 June 2012 - 06:03 AM
You are editing each computer's startup file instead of going into /rom/startup, correct? Each computer's startup file should have the program it needs to run in it.
Lazymuffin #9
Posted 29 June 2012 - 01:22 PM
I'm sorry I'm a total noob. I have no clue how to edit each separate computer's startup file.

edit: I found that just naming a programs "startup" in root directory works now. thanks for the help!
Deimos #10
Posted 29 November 2012 - 08:16 PM
Can anyone help me,

I am trying to do the same thing but am having a bit of a hard time.

I have tried

local monitorSide = "top" -- the side the monitor is on

if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  term.redirect(peripheral.wrap(monitorSide))
else
  print("No monitor found")
  return
end

local w,h = term.getSize()
term.clear()
term.setCursorPos(1,1)

local function printCenter(line)
	local width = string.len(line)
	if width < w then
		local x,y = term.getCursorPos()
		term.setCursorPos(w/2 - width/2,y)
	end
	print(line)
end

printCenter 'RULES'
print [[
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.techgalaxyminecraft.com'

term.restore()
shell.run("monitor","top","rules")
that displayed the rules until the chunk was unloaded

I have also tried
local w,h = term.getSize()
term.clear()
term.setCursorPos(1,1)

local function printCenter(line)
	local width = string.len(line)
	if width < w then
		local x,y = term.getCursorPos()
		term.setCursorPos(w/2 - width/2,y)
	end
	print(line)
end

printCenter 'RULES'
print [[
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.techgalaxyminecraft.com'
with the same startup code but I just cant get it to load when the chunk is reloaded/entered. if you could help that would be fantastic

Sorry for the necromancer act. I thought it better to post on a topic already than to start a whole new one for the same thing
russjr08 #11
Posted 29 November 2012 - 08:40 PM
You probably should have posted in a new topic, I was just about to reply until I saw the date. Unfortunately, unless I'm wrong, you need some kind of chunkloader (I haven't found a way for computers to auto-start themselves back up).
Deimos #12
Posted 29 November 2012 - 08:47 PM
hmm maybe a redstone current?
Luanub #13
Posted 29 November 2012 - 08:57 PM
Do you have the code in the startup file on the computer? If the computer was on prior to the chunk being unloaded when the chunk load the computer should be on. It will not be in the same location in the code(I think they are working on adding this into future releases) but it should be on and run the startup file if one exist.

Also what version of CC are you using? I can't remember for sure but I believe there may have been an issue in one of the older releases where this did not work right.
Deimos #14
Posted 29 November 2012 - 09:25 PM
im not sure what version tekkit 3.1.2 uses ( I think 1.33). I have the code saved in my programs file on the server not the computer. Should I type it out in to the computer?
Luanub #15
Posted 29 November 2012 - 09:31 PM
You should be able to run it from rom/programs. Just put something like shell.run("programName") in your startup file.
Deimos #16
Posted 29 November 2012 - 09:33 PM
That is what I have, shell.run("rules") will work and display the rules on the computer, but Im trying to have it show on a monitor so I have used
 shell.run("monitor","run",rules") the computer loads but doesnt display the rules on the screens
Luanub #17
Posted 29 November 2012 - 10:02 PM
If you run the first code with the term.redirect() you don't need to run it with the monitor program. Just shell.run("rules") should do it.
Deimos #18
Posted 30 November 2012 - 02:46 AM
so this one?

local monitorSide = "top" -- the side the monitor is on

if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  term.redirect(peripheral.wrap(monitorSide))
else
  print("No monitor found")
  return
end

local w,h = term.getSize()
term.clear()
term.setCursorPos(1,1)

local function printCenter(line)
		local width = string.len(line)
		if width < w then
				local x,y = term.getCursorPos()
				term.setCursorPos(w/2 - width/2,y)
		end
		print(line)
end

printCenter 'RULES'
print [[
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.techgalaxyminecraft.com'

term.restore()



Edit - no luck my good sir
Luanub #19
Posted 30 November 2012 - 10:35 AM
Well I've tested in Tekkit 3.1.2 SSP(unfortunately I don't have server software for 3.1.2 anymore) and it works as it should. I tested on Tekkit SMP 3.1.3 with CC 1.41 and it works fine. And I've tested on the latest MC/CC and it works fine.

So unless it's specifically an issue with Tekkit 3.1.2 SMP it should work, and if that is the case pretty much your only option is to update to Tekkit 3.1.3. Or if you can do without redpower start using something like Feed the beast which is on MC 1.4.2 with CC 1.46

Startup:

shell.run("rules")

Rules: (located in the rom/programs)

local monitorSide = "top" -- the side the monitor is on

if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  term.redirect(peripheral.wrap(monitorSide))
else
  print("No monitor found")
  return
end

local w,h = term.getSize()
term.clear()
term.setCursorPos(1,1)

local function printCenter(line)
                local width = string.len(line)
                if width < w then
                                local x,y = term.getCursorPos()
                                term.setCursorPos(w/2 - width/2,y)
                end
                print(line)
end

printCenter 'RULES'
print [[
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.techgalaxyminecraft.com'

term.restore()
Edited on 30 November 2012 - 09:37 AM
Deimos #20
Posted 30 November 2012 - 12:29 PM
yeah I have no idea whats happening. I loads and displays so I tp to my home which is 2000 blocks away come back and the computer is flashing but the monitor is blank. Thanks for your help dude.
Kingdaro #21
Posted 30 November 2012 - 12:34 PM
Try having the code on a loop? Maybe it needs to be redrawn once the chunk is reloaded.


local w,h = term.getSize()

local function printCenter(line)
  local width = string.len(line)
    if width < w then
      local x,y = term.getCursorPos()
      term.setCursorPos(w/2 - width/2,y)
    end
  print(line)
end

while true do
term.clear()
term.setCursorPos(1,1)

printCenter 'RULES'
print [[
1) No griefing*, if you are caught griefing you will be banned.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers, or advertise our server to others without consent.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.techgalaxyminecraft.com'

sleep(1)
end

Also while using the same "shell.run('monitor', 'top', 'rules')" code as before.

Also, did I write this code? It looks like I wrote this code a long time ago, haha.
Deimos #22
Posted 01 December 2012 - 02:51 AM
Yeah you may have one another forum. I asked for help and this is what I got :P/>/&amp;gt;

HUZZAH that did it thanks so much dude

I do have to turn the computer on when the server restarts however. Is there away to power it with redstone so it turns on?
Also is there away to make columns of text in lua? I want to put a list of something on a monitor but its a long list
would
 local myString = [[ text here ]] ]/code] work?
Deimos #23
Posted 01 December 2012 - 12:26 PM
double post by mistake
Kingdaro #24
Posted 01 December 2012 - 12:40 PM
Also is there away to make columns of text in lua? I want to put a list of something on a monitor but its a long list
would
 local myString = [[ text here ]] 
work?
I think textutils.tabulate does that.
Deimos #25
Posted 04 December 2012 - 02:12 PM
Does anyone know if there is a way to activate a computer with redstone? My computer turns off sometimes and I would like to keep it turned on
ChaddJackson12 #26
Posted 04 December 2012 - 02:17 PM
Does anyone know if there is a way to activate a computer with redstone? My computer turns off sometimes and I would like to keep it turned on
As far as I know, you'd have to keep the computer on and in a while loop with term.clear() until redstone is powered to the computer with os.pullEvent(). I don't think there is a way to have redstone power your computer while it is actually off.