NOTICE ( November 27th, 2014 ): I came back to find a ComputerCraft version for 1.8.1 and I see it still hasn't gotten to that point yet. I'm afraid that I will not bother with this site any longer since its dead. Sorry to see it go. It was the best mod around.
WHAT IT IS
This is a server template. It fully automates itself in the sense of finding all peripherals it needs… if you have them attached. It works on regular computers and advanced computers. Touch screen as well. This is the basic template I will be using for TorNet. You can add your own ideas into this template for your massive server projects.
MY DREAM OF COMPUTERCRAFT
Call me crazy, but I feel that TorNet could be better used if multiple servers all over the world that host minecraft, And they could display their websites right inside of computercraft. Think about it. Simple HTML websites FROM ANY TO ANY minecraft server. Well, its a dream that is VERY possible. With the PHP and the parsing of those files, you could literally have one server talk to another through a website. Of course you must setup a PHP website, but you technically could use this server template to do so. It's a dream of mine to make this happen. Who knows… :)/>
SERVER TEMPLATE ( Recommended ! )
Here is the pastebin for the template with a server locking mechanism built in so that if it sees another server with the same identification it will shut the newer server down.
NEWEST VERSION - 8.26.2013 ( Build 1531 )
pastebin get EeWG5PW3 template
Older Version
pastebin get W1UjG6ac template
SERVER TEMPLATE - NO LOCKING MECHANISM
Use this pastebin for the template if you do not want a locking mechanism.
pastebin get msun8KDc template
CHANGELOG
- 8.26.2013 ( Build 1531 )
– Added Server Identity Generation ( No need to edit the server file manually to change the server's identity. Still allows for custom identity, by editing the Ident File that is created. )
– Fixed setTextColor now has the appropriate Capital letter C.
- 8.16.2013 ( Build 840 )
– Fixed setTextColor now has the appropriate Capital letter C.
– Original version
DEMO
SERVER TEMPLATE DEMO - NO LOCKING MECHANISM ( Not recommended as your default. This is for demonstration purposes only ! )
Test my demo template example below on three different wireless computers and you will see them all communicate with each other. To initiate it, just hit the G key in one of the computers. The transmit and receive lights will go green.. on the black and white screen it shows 0 and 1.
The full code here
Spoiler
-- TorakTu - Template [ 8.15.2013.2006 ]
os.pullEvent = os.pullEventRaw
local mainName = "Template"
local em = "NONE"
local sides = {"left","right","top","bottom","back"}
local mSide = { }
local mtotal = 0
local isModem = 0
local off = 0
local mon = ""
local advancedornot = false
local currPath = shell.resolve(".")
local timer
local theSwitch = 0
local theTime = 0
local menu_options = 0
local trans = 0
local mScaleSize = 0.5
local setMonScale = 0
local tr = 0
if currPath == "disk" then currPath = "/disk/" end
for _,v in pairs(sides) do
if peripheral.getType(v) == "modem" then
mtotal = mtotal + 1
mSide[mtotal] = v
isModem = 1
end
if peripheral.getType(v) == "monitor" then
em = v
end
end
if isModem == 0 then
term.clear()
term.setCursorPos(1,1)
print(" ")
print(" WARNING ! No modem attached !")
print(" ")
print(" PROGRAM TERMINATED !")
print(" ")
return
end
local modem = peripheral.wrap(mSide[1])
if em ~= "NONE" or em == "bottom" or em == "top" or em == "left" or em == "right" or em == "back" then
mon = peripheral.wrap(em)
mon.setTextScale(0.5)
else
mon = "NONE"
end
if term.isColor() then
advancedornot = true
end
function mtprint(theString,x,y,fg,bg)
if mon ~= "NONE" then
if advancedornot then
if f ~= 0 then
mon.setTextColor(fg)
term.setTextColor(fg)
end
if b ~= 0 then
mon.setBackgroundColor(bg)
term.setBackgroundColor(bg)
end
end
mon.setCursorPos(x,y)
mon.write(theString)
term.setCursorPos(x,y)
term.write(theString)
else
if advancedornot then
if f ~= 0 then
term.setTextcolor(fg)
end
if b ~= 0 then
term.setBackgroundColor(bg)
end
end
term.setCursorPos(x,y)
term.write(theString)
end
end
function clearMe()
if mon ~= "NONE" then
if advancedornot then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.white)
end
mon.clear()
mon.setCursorPos(1,1)
term.clear()
term.setCursorPos(1,1)
else
if advancedornot then
term.setTextColor(colors.white)
term.setBackgroundColor(colors.black)
end
term.clear()
term.setCursorPos(1,1)
end
end
local settings = { }
settings.isonline = "offline"
function pscreen()
if settings.isonline == "online" then
mtprint(settings.isonline.." ",26,3,colors.green,colors.black)
else
mtprint(settings.isonline.." ",26,3,colors.red,colors.black)
end
mtprint(tostring(mSide[1]).." ",26,4,colors.cyan,colors.black)
end
function saveFile( file, data )
local f = fs.open( file, "w" )
f.write( data )
f.close()
end
function readFile( file )
if not fs.exists( file ) then return end
local f = fs.open( file, "r" )
local loadInfo = f.readAll()
f.close()
return loadInfo
end
function emodem()
if off == 0 then
settings.isonline = "offline"
modem.close(1)
end
if off == 1 then
settings.isonline = "online"
modem.open(1)
end
end
function mDraw()
mtprint(" ---------- ",3,7,colors.black,colors.brown)
mtprint("| Q - QUIT |",3,8,colors.black,colors.brown)
mtprint(" ---------- ",3,9,colors.black,colors.brown)
mtprint(" ---------- ",16,7,colors.black,colors.brown)
mtprint("|E - ENABLE|",16,8,colors.black,colors.brown)
mtprint(" ---------- ",16,9,colors.black,colors.brown)
end
function transmissions()
if trans == 0 then
tr = 0
mtprint("0",35,7,colors.gray,colors.gray)
mtprint("0",35,9,colors.gray,colors.gray)
end
if trans == 1 then
tr = 1
timer = os.startTimer(0.1)
mtprint("1",35,7,colors.green,colors.green)
end
if trans == 2 then
tr = 1
timer = os.startTimer(0.1)
mtprint("1",35,9,colors.green,colors.green)
end
end
clearMe()
mtprint(mainName,10,1,colors.red,colors.black)
mtprint("Server Status : ",5,3,colors.white,colors.black)
mtprint("Modem Side : ",5,4,colors.white,colors.black)
mtprint("Tx : ",30,7,colors.white,colors.black)
mtprint("Rx : ",30,9,colors.white,colors.black)
emodem()
pscreen()
mDraw()
while true do
if theTime == 1 then
timer = os.startTimer(0.1)
if theSwitch >= 1 then theSwitch = theSwitch - 1 end
if theSwitch <= 0 then
theSwitch = 0
theTime = 0
end
end
if off > 2 then off = 0 end
if theTime == 0 and theSwitch >= 1 then theSwitch = theSwitch - 1 end
if theSwitch <= 0 then
theSwitch = 0
theTime = 0
end
if tr >= 1 then
tr = tr - 1
else
if trans > 0 then
tr = 0
trans = 0
transmissions()
end
end
local evt, arg, xPos, yPos, message = os.pullEvent()
if evt == "timer" then
if tr > 0 then timer = os.startTimer(0.1) end
end
if evt == "modem_message" then
if settings.isonline == "online" then
if message == "test" then
trans = 1
transmissions()
modem.transmit(1,1,"test")
trans = 2
transmissions()
end
end
end
if evt == "char" then
local c = string.lower(arg)
if c == "g" then
modem.transmit(1,1,"test")
trans = 1
transmissions()
end
if c == "q" then
if off == 0 then
break
else
end
end
if c == "e" then
if theSwitch == 0 then
theTime = 1
theSwitch = 1
off = off + 1
if off >= 2 then off = 0 end
emodem()
pscreen()
end
end
end
if evt == "mouse_click" or evt == "monitor_touch" then
menu_options = 0
setMonScale = 0
if evt == "monitor_touch" then setMonScale = 1 end
if xPos >= 3 + setMonScale and xPos <= 14 + setMonScale and yPos >= 7 and yPos <= 9 then
menu_options = 1
end
if xPos >= 16 + (setMonScale / 2) and xPos <= 27 + setMonScale and yPos >= 7 and yPos <= 9 + (setMonScale / 2) then
menu_options = 2
end
if menu_options == 1 and off == 0 then
break
else
end
if menu_options == 2 then
off = off + 1
if off >= 2 then off = 0 end
emodem()
pscreen()
end
end
end
clearMe()
print(" ")
print("Program Terminated")
print(" ")
Enjoy…