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

Help with startup programs

Started by Deimos, 26 November 2012 - 11:42 AM
Deimos #1
Posted 26 November 2012 - 12:42 PM
Hi there guys,

I was wonder if anyone could help me. I would like to have my server rules, donator ranks and blacklisted items, displayed on a CC screen but Im not sure how to go about it.

I have these codes at the moment, but im not sure how to make them work as soon as the server is started/chunk is loaded.

Rules

Spoilerlocal 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) Donít 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'

Tier 1

Spoilerlocal 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 'Diamond (Tier1)'

print [[
* 5 homes
* Creative World access
* Showcase shop access
* Nicknames
* Full Dark Matter Amour
* Diamond tools kit
* Machine kit
32 circuits
32 machine blocks
64 insulated copper wire
* A one time payout of $10,000 &amp; a one time payout of 16 bottles of exp
* Access to level 1 collector
]]

printCenter 'Diamond Tier = $5.00 a month '
printCenter 'www.techgalaxyminecraft.com'

Tier 2

Spoilerlocal 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 'DarkMatter (Tier2)'

print [[
Ten homes.
Access to creative world.
Ability to create trade shops.
Nickname.
VIP job access.
Access to use LogBlock to look up block places and breaks.
2x buffer to McMMO skill gaining
25 extra town plots.
Compass travel.
Set of dark matter tools each real day.
Basic machine kit
1 macerator
1 extractor
1 compressor
1 electric furnace
One time payout of $50k.
Flight in Silfrax with a fuel kit (Swift ring)
32 experience bottles each real day.
VIP Mining world, that will be reset every month
* Access to collectors level 1 and 2
]]

printCenter 'Dark Matter Tier $10.00 a month '
printCenter 'www.techgalaxyminecraft.com'
printCenter 'Dark Matter Tier inherits T1 kits'


tier 3

Spoilerlocal 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 'RedMatter (Tier3)'

print [[
* Fifteen homes.
* Full Red Matter armour
* Access to creative world.
* Ability to create trade shops.
* Nickname.
* * VIP job access.
* Access to use LogBlock to look up block places and breaks.
* 3x buffer to McMMO skill gaining
* 50 extra town plots.
* Compass travel.
* Set of Red Matter tools (monthly)
* One time payout of $100k.
* 64 experience bottles each real day.
* Flight in Silfrax with a fuel kit (Swift ring)
* High level power
1 HV solar array (or panel instead)
1 MV transformer
1 MFE.
32 Glass Fibre Cable
* Ability to fly in the normal world.
* Access to all collectors levels
]]

printCenter 'Dark Matter Tier $15.00 a month '
printCenter 'www.techgalaxyminecraft.com'
printCenter 'RedMatter Tier inherits T1 &amp; T2 kits'

If you can help that would be fantastic

Thank you heaps in advance
ChunLing #2
Posted 26 November 2012 - 02:23 PM
Write a startup file that calls your program, or simply name the program startup.
Deimos #3
Posted 26 November 2012 - 04:40 PM
Sorry Im rather new to LUA

So should I just edit my startup script so its like this?

Spoilerlocal sPath = ".:/rom/programs"
if turtle then
sPath = sPath..":/rom/programs/turtle"
else
sPath = sPath..":/rom/programs/computer"
sPath = sPath..":/rom/programs/rules"
end
if http then
sPath = sPath..":/rom/programs/http"
end

shell.setPath( sPath )
help.setPath( "/rom/help" )

shell.setAlias( "ls", "list" )
shell.setAlias( "dir", "list" )
shell.setAlias( "cp", "copy" )
shell.setAlias( "mv", "move" )
shell.setAlias( "rm", "delete" )

if fs.exists( "/rom/autorun" ) and fs.isDir( "/rom/autorun" ) then
local tFiles = fs.list( "/rom/autorun" )
table.sort( tFiles )
for n, sFile in ipairs( tFiles ) do
if string.sub( sFile, 1, 1 ) ~= "." then
local sPath = "/rom/autorun/"..sFile
if not fs.isDir( sPath ) then
shell.run( sPath )
end
end
end
end

Sorry like I said im new to lua and have no idea what im doing :P/>
ChunLing #4
Posted 26 November 2012 - 05:27 PM
DO NOT edit the existing startup script in /rom.

Just have a file in your computer's local storage, in the root directory (NOT in /rom) called startup. It can be the program that you want to run at startup or it can be a short program that uses shell.run() to load another program (with command line options, even).

For instance, if you wanted to have four files named for the different displays they put up, you could create a startup file like so:
while true do
  shell.run("rules")
  sleep(15) --adjust the seconds for how long you want to leave the display up before switching to the next
  shell.run("tier1")
  sleep(15)
  shell.run("tier2")
  sleep(15)
  shell.run("tier3")
  sleep(15)
  shell.run("tier4")
  sleep(15)
end
Or you can just put all the display code into startup, separated by sleeps and contained in a loop.
Deimos #5
Posted 26 November 2012 - 06:47 PM
Ok so I have done
shell.run("monitor","top","rules")

So now when the server starts or the that chunk is loaded will it start right away?

The codes were not all for the one screen.
ChunLing #6
Posted 26 November 2012 - 06:55 PM
It should, if typing "monitor top rules" is how you start your program. Logout or go to the Nether or whatever so that the chunks unload, then come back and see.
Deimos #7
Posted 26 November 2012 - 11:24 PM
Thanks so much for you help, One more thing. Is there away I can make the computer only run that program and make it so people can not edit it or run another program?
ChunLing #8
Posted 27 November 2012 - 12:02 AM
Yes, there are three aspects to this.

First, you have to put the computer somewhere that it cannot be easily accessed except from a single direction. The key point is that if someone puts a disk drive next to the computer they will no longer be able to use the computer (there is no way to prevent a computer running disk/startup on bootup).

Second, you need to ensure that there is no normal way to exit the program. Just put an infinite loop at the end of the program (possibly one that periodically refreshes your message).

Third, you need to redefine os.pullEvent() so that it uses os.pullEventRaw() and intercepts the Ctrl+T "Terminate" event to prevent that means of exiting the program.

At this point, the only ways to exit your program are to use Ctrl+S/R to reboot the computer, to go far enough away that the chunk unloads, and to break the computer.

The first two will just cause startup to run again, but the last is a problem that programming the computer won't fix (there are various ways to prevent it, of course).

If you don't need access to the computer yourself, then just wall the thing up entirely once it's set up.
Deimos #9
Posted 27 November 2012 - 12:18 AM
Thanks mate, I have gone down the "wall up" road as I dont need to use that computer once its running.

I do have one small problem.

As you know I have the startup program to run

shell.run("monitor","top","rules")

Which works fine apart from the screen I have at spawn. I have a test screen set up almost 7k blocks away and that one hasnt stopped working since you told me to use the startup program, but this one in spawn seems to stop working when th echunk unloads. It is running the same startup script so no clue whats going wrong.
Deimos #10
Posted 28 November 2012 - 09:40 AM
hey guys, im having a bit of a problem with my startup script.


shell.run("monitor","top","rules")

The computer is loading but it is not displaying the text on the screen.
ChunLing #11
Posted 29 November 2012 - 08:03 AM
Sorry, I've been a bit sick.

Do you have any kind of spawn area protection setup? If so, it could be preventing the computer from modifying the monitor blocks somehow. I'm not completely sure of all the ins and outs of that kind of thing, though.
Deimos #12
Posted 29 November 2012 - 03:52 PM
It is towny protected.
ChunLing #13
Posted 30 November 2012 - 09:46 AM
Hmm…just to be sure, check that the exact same program will work fine outside of the protected area.

Anyway, a possible fix would be to use a chunk anchor to ensure that the computer doesn't need to restart, if the problem only occurs when the computer is restarting itself.
Deimos #14
Posted 04 December 2012 - 08:13 PM
Third, you need to redefine os.pullEvent() so that it uses os.pullEventRaw() and intercepts the Ctrl+T "Terminate" event to prevent that means of exiting the program.
How would one do this ? do I just put os.pullEventRaw() at the top of the code?

I have sort of a Automatic helpdesk computer set up where people select info from a list on a computer so I cant hide the computers :P/>
ChunLing #15
Posted 04 December 2012 - 08:32 PM
A lot of people just back up os.pullEvent and then set it equal to os.pullEventRaw, like so:
pullBackup = os.pullEvent
os.pullEvent = os.pullEventRaw
There's a function replacement tutorial that discusses this sort of thing, with that as one of the examples. I've been fond of the idea of writing a function that actually did something if someone did press Ctrl+T, and I don't mean screen output telling them that won't work (though that is a possibility).

Anyway, make sure that people can only access one side of the computer. That way, if they try to stick a drive with a startup disk on the computer, they can't access it anymore to force a shutdown. Then you have plenty of time to check for if there's a disk/startup file, and delete it.
Deimos #16
Posted 04 December 2012 - 09:02 PM
Thanks for your help.
One last question, Is there away to tell who has edited a program?
ChunLing #17
Posted 04 December 2012 - 09:28 PM
No. There isn't any way to tell one user from another, even when they are actually providing input. I mean, you can probably do some profiler magic to guess who edited something, but the computer can't tell.
Deimos #18
Posted 05 December 2012 - 12:39 AM
Ok thanks, just wanted to know if I could tell who f****d with my computers,

I have it all sorted now thanks.

Now to figure out how to make tables in LUA :P/>
ChunLing #19
Posted 05 December 2012 - 10:54 AM
Have an anti-griefer trap and look for who's on fire.

Tables are defined like, "a_table = {}", and accessed like, "a_table[index_value]". You can use an integer or a string for index_value, by default tables provided with entries will index them by sequential numbers starting with one. So, "a_table = {"hi",5,true,{},function() print("hello") end}" will mean the following:
a_table[1] contains the string "hi"
a_table[2] contains the number 5
a_table[3] contains the boolean value true
a_table[4] contains an empty table
a_table[5] contains a function that prints "hello", you can call it like a_table[4]()

Usually you won't do anything that random with a sequential table. But you can.
Deimos #20
Posted 05 December 2012 - 09:54 PM
O.o so if I wanted to make a list of say banned items I would do

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)

"a_table={print("Triangulator,  TnT,  DragonEgg,  Engery Collector 1,  Engery Collector 2,  Engery Collector 3,  Nova Catalyst,  Nova Cataclysm,  DM pedestal,  Project Table,  Block Breaker,  Filler,  Builder,  EnderChest,  Teleport Tether,  World Anchor,  Turtles,  nuke,  Blaze Rods"), print("Dimensional Anchor, TnT Cart, MFE Cart, wooden Spear, stone Spear, Iron Spear, Diamond Spear, Gold Spear, Wood Knife, Stone Knife, Iron Knife, Diamond Knife, Gold Knife, Javelin, Musket, Musket with Bayonet, Crossbow, Blowgun, Dynamite, Cannon, Blunderbuss"), print("Destruction Catalyst, Evertide Amulet, Volcanite Amulet, Black Hole Band, Ring of Ignition, Hyperkinetic Lens, Watch of flowing time, Dark Matter Hammer, Catalytic Lens, Red Matter Katar, Red Matter Morning Star, Zero Ring, Infernal Armor, Abyss Helmet, Gravity Greaves, Hurricane Boots, Mercurial Eye, Ring of Arcana, Void Ring, Mining Laser")end)}"
sleep(1)
end
bjornir90 #21
Posted 06 December 2012 - 03:00 AM
O.o so if I wanted to make a list of say banned items I would do

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)

"a_table={print("Triangulator,  TnT,  DragonEgg,  Engery Collector 1,  Engery Collector 2,  Engery Collector 3,  Nova Catalyst,  Nova Cataclysm,  DM pedestal,  Project Table,  Block Breaker,  Filler,  Builder,  EnderChest,  Teleport Tether,  World Anchor,  Turtles,  nuke,  Blaze Rods"), print("Dimensional Anchor, TnT Cart, MFE Cart, wooden Spear, stone Spear, Iron Spear, Diamond Spear, Gold Spear, Wood Knife, Stone Knife, Iron Knife, Diamond Knife, Gold Knife, Javelin, Musket, Musket with Bayonet, Crossbow, Blowgun, Dynamite, Cannon, Blunderbuss"), print("Destruction Catalyst, Evertide Amulet, Volcanite Amulet, Black Hole Band, Ring of Ignition, Hyperkinetic Lens, Watch of flowing time, Dark Matter Hammer, Catalytic Lens, Red Matter Katar, Red Matter Morning Star, Zero Ring, Infernal Armor, Abyss Helmet, Gravity Greaves, Hurricane Boots, Mercurial Eye, Ring of Arcana, Void Ring, Mining Laser")end)}"
sleep(1)
end
I'm not sure you can put a function in a table
ChunLing #22
Posted 06 December 2012 - 06:18 AM
You can put pretty much anything in lua in a table. Especially functions, for those who are novices in CC and don't know how to use tables, because all the apis build tables of functions.
bjornir90 #23
Posted 06 December 2012 - 06:31 AM
Oh ok don't know that, thanks :)/>
Deimos #24
Posted 06 December 2012 - 09:50 AM
Hmm I tested out my code and it errors out on line 16 somehting about the = expected .
Lyqyd #25
Posted 06 December 2012 - 11:12 AM
Please post the full current code and the full error message.
Deimos #26
Posted 06 December 2012 - 06:35 PM

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)

"a_table={print("Triangulator,  TnT,  DragonEgg,  Engery Collector 1,  Engery Collector 2,  Engery Collector 3,  Nova Catalyst,  Nova Cataclysm,  DM pedestal,  Project Table,  Block Breaker,  Filler,  Builder,  EnderChest,  Teleport Tether,  World Anchor,  Turtles,  nuke,  Blaze Rods"), print("Dimensional Anchor, TnT Cart, MFE Cart, wooden Spear, stone Spear, Iron Spear, Diamond Spear, Gold Spear, Wood Knife, Stone Knife, Iron Knife, Diamond Knife, Gold Knife, Javelin, Musket, Musket with Bayonet, Crossbow, Blowgun, Dynamite, Cannon, Blunderbuss"), print("Destruction Catalyst, Evertide Amulet, Volcanite Amulet, Black Hole Band, Ring of Ignition, Hyperkinetic Lens, Watch of flowing time, Dark Matter Hammer, Catalytic Lens, Red Matter Katar, Red Matter Morning Star, Zero Ring, Infernal Armor, Abyss Helmet, Gravity Greaves, Hurricane Boots, Mercurial Eye, Ring of Arcana, Void Ring, Mining Laser")end)}"
sleep(1)
end

bios:206: [string "banned"]:16: '=' expected
ChunLing #27
Posted 06 December 2012 - 07:57 PM
You put a double quote in front of "a_table={print(" turning that into a string and Triangulator into an identifier. That messes up the whole thing.

The contents of the table are wonky. Do you want those to be functions in the table? To do that, it would need to be:
a_table={function() print("Triangulator,  TnT,  DragonEgg,  Engery Collector 1,  Engery Collector 2,  Engery Collector 3,  Nova Catalyst,  Nova Cataclysm,  DM pedestal,  Project Table,  Block Breaker,  Filler,  Builder,  EnderChest,  Teleport Tether,  World Anchor,  Turtles,  nuke,  Blaze Rods") end,
    function() print("Dimensional Anchor, TnT Cart, MFE Cart, wooden Spear, stone Spear, Iron Spear, Diamond Spear, Gold Spear, Wood Knife, Stone Knife, Iron Knife, Diamond Knife, Gold Knife, Javelin, Musket, Musket with Bayonet, Crossbow, Blowgun, Dynamite, Cannon, Blunderbuss") end,
    function() print("Destruction Catalyst, Evertide Amulet, Volcanite Amulet, Black Hole Band, Ring of Ignition, Hyperkinetic Lens, Watch of flowing time, Dark Matter Hammer, Catalytic Lens, Red Matter Katar, Red Matter Morning Star, Zero Ring, Infernal Armor, Abyss Helmet, Gravity Greaves, Hurricane Boots, Mercurial Eye, Ring of Arcana, Void Ring, Mining Laser") end
}
But there's no point in having that be a table of functions for two reasons. First off, you never call any of the functions from the table. Second, and more profoundly, you could just have the strings in the table and use print(a_table) (i being the index of the string you want to print).
Deimos #28
Posted 06 December 2012 - 11:53 PM
I jsut want a three lists so I can display my banned items :P/>
As you can tell im a noob when it comes to this stuff.
ChunLing #29
Posted 07 December 2012 - 12:22 AM
Just put the strings in the table and then use print(a_table) to print out the strings (you'll want to be formatting them some, the [[]] style of string can help with that).
a_table={
  [[Triangulator,  TnT,  DragonEgg,  Engery Collector 1,  Engery Collector 2,
Engery Collector 3,  Nova Catalyst,  Nova Cataclysm,  DM pedestal,
Project Table,  Block Breaker,  Filler,  Builder,  EnderChest,  Teleport Tether,
World Anchor,  Turtles,  nuke,  Blaze Rods]],
  [[Dimensional Anchor, TnT Cart, MFE Cart, wooden Spear, stone Spear,
Iron Spear, Diamond Spear, Gold Spear, Wood Knife, Stone Knife, Iron Knife,
Diamond Knife, Gold Knife, Javelin, Musket, Musket with Bayonet, Crossbow,
Blowgun, Dynamite, Cannon, Blunderbuss]],
  [[Destruction Catalyst, Evertide Amulet, Volcanite Amulet, Black Hole Band,
Ring of Ignition, Hyperkinetic Lens, Watch of flowing time, Dark Matter Hammer,
Catalytic Lens, Red Matter Katar, Red Matter Morning Star, Zero Ring,
Infernal Armor, Abyss Helmet, Gravity Greaves, Hurricane Boots, Mercurial Eye,
Ring of Arcana, Void Ring, Mining Laser]]
} -- double brackets allow you to easily include line returns in your strings, for easier formatting

while true do
  for i = 1,#a_table do
    print(a_table[i])
    sleep(5)
  end
end
Now, that centered print function you had in the other code will only work with a single line short enough to fit on the screen. So if you want to use that, then you can just have more separate strings.
Deimos #30
Posted 07 December 2012 - 12:40 AM
Thanks for your help dude.

If I try to use that code you made for me I get
Bios:206: [string "Startup:] :1: unfisinhed string

So I tried monitor right banned to see what it looked like and it was sort of just displaying it in lines and waiting 5seconds before it went to the next lot.
What Im trying to do is have the items in like columns
ChunLing #31
Posted 07 December 2012 - 07:50 AM
Huh…that shouldn't have happened.

Well, the [[string]] wasn't really to your needs, if you want it line by line. Just go with regular "string" notation, keep the whole string on a line.
local a_table={
  "Triangulator      TnT       DragonEgg",
  "Engery Collector 1  Engery Collector 2    Engery Collector 3",
  "Nova Catalyst   Nova Cataclysm   DM pedestal",
  "Project Table  Block Breaker   Filler",
  "Builder   EnderChest   Teleport Tether",
  "World Anchor   Turtles   nuke",
  "Blaze Rods  Dimensional Anchor  TnT Cart",
  "MFE Cart   wooden Spear  stone Spear",
  "Iron Spear  Diamond Spear  Gold Spear",
  "Wood Knife  Stone Knife  Iron Knife",
  "Diamond Knife  Gold Knife  Javelin",
  "Musket  Musket with Bayonet  Crossbow",
  "Blowgun  Dynamite  Cannon  Blunderbuss",
  "Destruction Catalyst  Evertide Amulet  Volcanite Amulet",
  "Black Hole Band  Ring of Ignition  Hyperkinetic Lens",
  "Watch of flowing time  Dark Matter Hammer  Catalytic Lens",
  "Red Matter Katar  Red Matter Morning Star  Zero Ring",
  "Infernal Armor  Abyss Helmet  Gravity Greaves",
  "Hurricane Boots  Mercurial Eye, Ring of Arcana",
  "Void Ring  Mining Laser",
}
while true do
  for i = 1,#a_table do
    print(a_table[i])
    sleep(.5)
  end
end
You'll need to format the strings to fit on your monitor and look how you want, the size disparity of some of those item descriptions is awkward. Expected behavior is to add a new line of the table text every half-second.
Deimos #32
Posted 07 December 2012 - 09:03 PM
And to stop it printing lines?

I am trying

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

printCenter 'Banned Items'

local a_table={
  "Triangulator	  TnT	   DragonEgg",
  "Engery Collector 1  Engery Collector 2	Engery Collector 3",
  "Nova Catalyst   Nova Cataclysm   DM pedestal",
  "Project Table  Block Breaker   Filler",
  "Builder   EnderChest   Teleport Tether",
  "World Anchor   Turtles   nuke",
  "Blaze Rods  Dimensional Anchor  TnT Cart",
  "MFE Cart   wooden Spear  stone Spear",
  "Iron Spear  Diamond Spear  Gold Spear",
  "Wood Knife  Stone Knife  Iron Knife",
  "Diamond Knife  Gold Knife  Javelin",
  "Musket  Musket with Bayonet  Crossbow",
  "Blowgun  Dynamite  Cannon  Blunderbuss",
  "Destruction Catalyst  Evertide Amulet  Volcanite Amulet",
  "Black Hole Band  Ring of Ignition  Hyperkinetic Lens",
  "Watch of flowing time  Dark Matter Hammer  Catalytic Lens",
  "Red Matter Katar  Red Matter Morning Star  Zero Ring",
  "Infernal Armor  Abyss Helmet  Gravity Greaves",
  "Hurricane Boots  Mercurial Eye, Ring of Arcana",
  "Void Ring  Mining Laser",}
end
So it prints Banned Items in themiddle and then the list.
but im getting the error bios:206: [String "banned"] :35: '<EOF>' expected
ChunLing #33
Posted 07 December 2012 - 10:06 PM
Yeah, you've got an extra end there. Or, you're leaving out the rest of the while loop that runs the program.

The previous post has an infinite loop of a for loop that traverses the table and prints out the next line of text from the table every half-second. This creates a continuously strolling display. To use the printCenter function, just swap that out for the print call.
Deimos #34
Posted 07 December 2012 - 11:10 PM
its obvious that I dont know what the hell im doing but I really am trying to understand this all.

The strolling display was a bit "busy" :P/> A static display is fine.
ChunLing #35
Posted 08 December 2012 - 05:35 AM
Then you want to eliminate the sleep and the while true loop, so that everything is written just once. You also don't really need the table either, just a single string with line returns. Like:
print([[Triangulator   TnT      DragonEgg
Engery Collector 1  Engery Collector 2       Engery Collector 3
Nova Catalyst   Nova Cataclysm   DM pedestal
Project Table  Block Breaker   Filler
Builder   EnderChest   Teleport Tether
World Anchor   Turtles   nuke
Blaze Rods  Dimensional Anchor  TnT Cart
MFE Cart   wooden Spear  stone Spear
Iron Spear  Diamond Spear  Gold Spear
Wood Knife  Stone Knife  Iron Knife
Diamond Knife  Gold Knife  Javelin
Musket  Musket with Bayonet  Crossbow
Blowgun  Dynamite  Cannon  Blunderbuss
Destruction Catalyst  Evertide Amulet  Volcanite Amulet
Black Hole Band  Ring of Ignition  Hyperkinetic Lens
Watch of flowing time  Dark Matter Hammer  Catalytic Lens
Red Matter Katar  Red Matter Morning Star  Zero Ring
Infernal Armor  Abyss Helmet  Gravity Greaves
Hurricane Boots  Mercurial Eye, Ring of Arcana
Void Ring  Mining Laser]])
But the problem is if all that will fit on one screen. If not then you might need to loop two print commands with sleep(5) between, so that the screen alternated.
Deimos #36
Posted 10 December 2012 - 10:20 PM
Thanks mate I have the code working now.


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

printCenter 'Banned Items'
printCenter ''
print([[Abyss Helmet   Anchor Cart    Black Hole Band
Blaze Rods	 Block Breaker  Builder
Cannon					    Catalytic Lens
Collector MK1  Collector MK2  Collector MK3
DM pedestal    DM Hammer	  Dest. Catalyst
DragonEgg	  Dynamite	   EnderChest
Evertide Amulet Filler	    Gravity Greaves
HurricaneBoots HyperkineticLens Infernal Armor
MFE Cart	   Mercurial Eye  Mining Laser
Nova Cataclysm Nova Catalyst  Nuke
Project Table  RM Armour	  RM Furnace
RM Katar	   RM MorningStar RM Tools
Ranged Weapons Ring of Arcana Ring of Ignition
SwiftWolf Ring Tank Cart	  Teleport Tether
TnT						   TnT Cart	   
Triangulator				  Transmutation Tablet
Turtles	    Void Ring	  Volcanite Amulet
		   Watch of flowing time
World Anchor				  Zero Ring]])
printCenter ''
printCenter ''
printCenter 'Collectors, RM Tool, RM Armour and Swiftwolf'
printCenter 'are Donator only'
printCenter ''
printCenter 'These items may change at anytime,'
printCenter 'please check back often to see'
printCenter 'if anything has changed'
printCenter ''
printCenter 'Banned items will turn to dirt'
printCenter 'if you craft them.This is at your expense'
printCenter 'and staff will not refund the items'
l
I am having an issue with my monitor for this code though. The computer will start up but it wont display the code until I break a computer screen and then put it back. Then it misses the last part of the code

printCenter 'Banned items will turn to dirt'
printCenter 'if you craft them.This is at your expense'
printCenter 'and staff will not refund the items'

My monitor is 5x6high, any advise?
ChunLing #37
Posted 12 December 2012 - 01:08 PM
Monitors aren't really my thing. But you'll probably need to include code to wrap the monitor and then redirect the terminal to it before calling your printCenter function. Like: term.redirect(peripheral.wrap("top")) or wherever your monitor is.