In game name: Neckername Age: 18 Programming languages: C/C++, C#, Java, a little Python. Anything Else: Have never touched Lua until I got the ComputerCraft mod a few days ago. Been doing some editing of programs in Notepad++. Have made a few basic programs such as "Hello World" and some that ask for a password, and verify. I have also dabbled slightly in html and ruby as well, but don't ask me to recall any of it haha.
Also, figured I should add an example of what I did in my Java class last year at college. Third project we had to make a grading organizer application, here is what I got, a very inefficient, but working, .java program.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import javax.swing.JDialog;
import javax.swing.JOptionPane;
public class Proj3
{
public static void main(String[] args)
{
String name0;
String first0; // strings for 5 students, sep strings for first and last names.
String last0;
String name1;
String first1;
String last1;
String name2;
String first2;
String last2;
String name3;
String first3;
String last3;
String name4;
String first4;
String last4;
//First student name
name0 = JOptionPane.showInputDialog("Please enter the first student's name in the following format: (first last).");
name0 = name0.trim();
int first0Index0 = 0;
int spaceIndex0 = name0.indexOf(" ");
int last0Index0 = spaceIndex0 + 1;
first0 = name0.substring(0, spaceIndex0);
last0 = name0.substring(last0Index0);
//First student grade
String grade0 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the first student.");
double nGrade0 = java.lang.Integer.parseInt(grade0);
double dGrade0 = (nGrade0 / 150);
double pGrade0 = Math.rint(dGrade0 * 100);
//Second student name
name1 = JOptionPane.showInputDialog("Please enter the second student's name in the following format: (first last).");
name1 = name1.trim();
int first1Index1 = 0;
int spaceIndex1 = name1.indexOf(" ");
int last1Index1 = spaceIndex1 + 1;
first1 = name1.substring(0, spaceIndex1);
last1 = name1.substring(last1Index1);
//Second student grade
String grade1 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the second student.");
double nGrade1 = java.lang.Integer.parseInt(grade1);
double dGrade1 = (nGrade1 / 150);
double pGrade1 = Math.rint(dGrade1 * 100);
//Third student name
name2 = JOptionPane.showInputDialog("Please enter the third student's name in the following format: (first last).");
name2 = name2.trim();
int first2Index2 = 0;
int spaceIndex2 = name2.indexOf(" ");
int last2Index2 = spaceIndex2 + 1;
first2 = name2.substring(0, spaceIndex2);
last2 = name2.substring(last2Index2);
//Third student grade
String grade2 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the third student.");
double nGrade2 = java.lang.Integer.parseInt(grade2);
double dGrade2 = (nGrade2 / 150);
double pGrade2 = Math.rint(dGrade2 * 100);
//Fourth student name
name3 = JOptionPane.showInputDialog("Please enter the fourth student's name in the following format: (first last).");
name3 = name3.trim();
int first3Index3 = 0;
int spaceIndex3 = name3.indexOf(" ");
int last3Index3 = spaceIndex3 + 1;
first3 = name3.substring(0, spaceIndex3);
last3 = name3.substring(last3Index3);
//Fourth student grade
String grade3 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the fourth student.");
double nGrade3 = java.lang.Integer.parseInt(grade3);
double dGrade3 = (nGrade3 / 150);
double pGrade3 = Math.rint(dGrade3 * 100);
//Fifth student name
name4 = JOptionPane.showInputDialog("Please enter the fifth student's name in the following format: (first last).");
name4 = name4.trim();
int first4Index4 = 0;
int spaceIndex4 = name4.indexOf(" ");
int last4Index4 = spaceIndex4 + 1;
first4 = name4.substring(0, spaceIndex4);
last4 = name4.substring(last4Index4);
//Fifth student grade
String grade4 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the fifth student.");
double nGrade4 = java.lang.Integer.parseInt(grade4);
double dGrade4 = (nGrade4 / 150);
double pGrade4 = Math.rint(dGrade4 * 100);
//Final Output
String out0 = ("Test Results: " + last0 + ", " + first0 + " got " + pGrade0 + " points on the test. The difference between the class average was " + avDiff00 + " points. " + last1 + ", " + first1 + " got " + pGrade1 + " points on the test. The difference between the class average was " + avDiff11 + " points. " + last2 + ", " + first2 + " got " + pGrade2 + " points on the test. The difference between the class average was " + avDiff22 + " points. " + last3 + ", " + first3 + " got " + pGrade3 + "points on the test. The difference between the class average was " + avDiff33 + " points. " + last4 + ", " + first4 + " got " + pGrade4 + " points on the test. The difference between the class average was " + avDiff44 + " points. The class average = " + finalG1 + " points.");
JOptionPane optionPane = new NarrowOptionPane();
optionPane.setMessage(out0);
optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog(null, "Results");
dialog.setVisible(true);
}
}
/*This code prevents the window from resulting in one line across the screen
by limiting the number of characters a line may contain in the resulting dialog box
*/
class NarrowOptionPane extends JOptionPane {
NarrowOptionPane() {
}
public int getMaxCharactersPerLineCount() {
return 64;
}
JPiolho, Darkhog, ash5784, Jkjkelly1, McLovn73, Neckername and duff650 added to whitelist.
@Assassin55 there's sadly nothing I can do about it, as I cannot install anti-grief plugins :sad.gif: (computercraft don't support Bukkit)
@ihaveamac The server gets very laggy after a while of playing. I am 99% sure it's COmputerCraft's fault, but I'm constantly looking for a fix.
* In game name:DoubleTap1911
* Age (minimum 12 years):13
* Screenshot/world save/text file/anything that shows
that you know programming: I know some html, i know just a little lua!
<HTML><Body>
hi!
This is a heading1
This is a heading12
This is a heading123
</body>
</html>
print ("Your Computer, will now reboot.")
sleep (2)
os.reboot
In game name: falloutfan101
Age (minimum 12 years): 13
Screenshot/world save/text file/anything that shows that you know LUA:
Additional anything: do those count /\?
-- return colorcode for choice
return colorStringTable[choice][2]
end
local function explode(d,p)
local t, ll
t={}
ll=0
if(#p == 1) then return {p} end
while true do
l=string.find(p,d,ll,true) -- find the next d in the string
if l~=nil then -- if "not not" found then..
table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
ll=l+1 -- save just after where we found it for searching next time.
else
table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
break -- Break at end, as it should be, according to the lua manual.
end
end
return t
end
local function setTable(key)
local numelements = 0
table = {}
for i=1,numelements,1 do
table[i] = setColorForKey(key .. "[" .. string.format("%i",i) .. "]")
end
return table
end
local function savetable(table, filename)
file = fs.open(filename, "w")
for key,value in pairs(table) do
if type(value) == "number" then
file.write(key .. "=" .. string.format("%i", value))
elseif type(value) == "table" then
file.write( key .. "={" )
for subindex,subentry in ipairs(value) do
file.write(string.format("%i", subentry))
if subindex < #value then
file.write(",")
end
end
file.write("}")
end
file.write("\n")
end
file:close()
end
local function loadtable(loadedtable, sPath)
local tLines = {}
local file, error = io.open( sPath, "r" )
local sLine = file:read()
while sLine do
table.insert( tLines, sLine )
sLine = file:read()
end
file:close()
for linenr,line in ipairs(tLines) do
parts = explode("=", line)
if #parts == 2 then
value = 0
if string.sub(parts[2], 0,1) == "{" then
numberstr = string.sub(parts[2], 2, string.len(parts[2])-1)
value = {}
if string.find(numberstr, ",", 1, true) ~= nil then
for a in string.gmatch(numberstr, "([^,]+),?") do
table.insert(value, tonumber(a))
end
else
table.insert(value, tonumber(numberstr))
end
else
value = tonumber(parts[2])
end
loadedtable[ parts[1] ] = value
end
end
end
local function definetable(table)
for key,value in pairs(table) do
if type(value) == "number" then
table[key] = setColorForKey(key)
elseif type(value) == "table" then
table[key] = setTable(key)
end
end
end
function configure(iotable, tablefile, force)
if fs.exists(tablefile) and force ~= true then
loadtable(iotable, tablefile)
else
definetable(iotable)
savetable(iotable, tablefile)
term.write("Wrote new Config. Rebooting in ")
sleep(1)
term.write(" 3 ")
sleep(1)
term.write(" 2 ")
sleep(1)
term.write(" 1 ")
sleep(1)
os.reboot()
end
end
--[[
local tArgs = {...}
local bool_forceNewConfig
-- if we passed "config", force configuration
if #tArgs == 1 and tArgs[1] == "config" then
bool_forceNewConfig = true
else
bool_forceNewConfig = false
end
-- import my program
dofile("configurator")
-- create a table
myBundledIosTable = {}
-- add some keys
-- either define type as number
myBundledIosTable.anInput = 0
-- or as an empty table
myBundledIosTable.someTransposers = {}
myBundledIosTable.someSensors = {}
-- call configure
-- when "configfile" doesn't exist, a gui lets the user configure values
-- saves them to said file and reboots.
-- successive runs of this program will then load the configfile,
-- no user interaction will be needed anymore.
-- by setting "bool_forceNewConfig" to true, a new config can be forced, regardless
-- if "configfile" is present or not
-- now we do some stuff
while true do
event, p1, p2 = os.pullEvent()
if event == "redstone" then
-- test our input
inputActive = redstone.testBundledInput("back", myBundledIosTable.anInput)
transposerColors = 0
-- create a selection of all transposers
for i=0,1,#myBundledIosTable.someTransposers do
transposerColors = colors.combine(transposerColors, myBundledIosTable.someTransposers[i])
end
-- pulse above selection for 0.1 seconds
redstone.setBundledOutput("back", transposerColors)
sleep(0.1)
redstone.setBundledOutput("back", 0)
end
end
]]--
* Additional anything: Love computercraft, I know lua quite a lot. I just got computercraf t a week ago. That was my first machine in the video, that's why it's so horrible.
Any additional info : I've been searching for a minecraft server with Buildcraft, Redpower, and ComputerCraft. But you have to pay for them. So I'll go with computercraft! :smile.gif:
Hi, I heard about computercraft and lua three days ago for the first time, but
it was not too hard for me to learn basic stuff and play a bit around with it.
I'm still learning and I would love to do that on a server with others who are (most likely)
more advanced than me!
ingame name: johnjonny123
age: 16(since a few days :tongue.gif:)
what i made first was the classic password door:
enter = "enter password"
help = "help"
print("for help type 'help'")
print("for to enter the password type 'enter password'")
instru = read()
if instru == (help) then
sleep(1)
print("'")
print("after the correct password was entered")
sleep(3)
print("'")
print("please walk down the path to your right")
sleep(3)
print("'")
print("do NOT hesitate")
sleep(3)
print("'")
print("at the end of the path is the elevator")
sleep(3)
print("'")
print("once again do NOT hesitate and place yourself in the middle of it!!!")
sleep(6)
print("'")
print("now enter the password")
sleep(5)
print("restart")
os.reboot()
end
if instru == (enter) then
password = read()
end
if password == (escapeword) then
print("!!!!!!!!!")
print("!exactly!")
print("!!!!!!!!!")
sleep(5)
redstone.setOutput("back", true)
sleep(20)
redstone.setOutput("back", false)
else print("that was not correct")
sleep(3)
print("the system will now shutdown for security reasons")
sleep(3)
print("for to try again please start the computer again")
sleep(3)
end
os.shutdown()
And i found a way to prevent people (me, since i did it in singelplayer XD) from doing what they want with the computer
by modifying the startup thing with shell.run("disk/program") and os.shutdown()
now i wrote the "program" on the disk that simply starts another program, for example my password-program . The cool thing about that is that i can control in game which program the computer will be running simply by changing the disk.
If somebody starts the computer and there is no disk with the "program" on it it will shut down.
if somebody knows the command for to restart a program without exit it or running another program please tell me!
dimitriye98 and falloutfan101, can you please show me a little more advanced programs?
@Xeonic97 He is now banned.
passcode="passwordHere"
debugcode="debug"
doorside="left"
while true do
local in=io.read()
if in == passcode then
rs.setOutput(doorside, true)
os.sleep(2)
rs.setOutput(doorside, false)
elseif in == debugcode then
break
else
print("Access Denied.")
end
end
Good enough?
My Lua's a bit rusty since it's been some time since I last wrote anything serious using it, but I hope this is good enough.
* In game name: gbear605
* Age (minimum 12 years): 12, but I'll be 13 in a month
* Screenshot/world save/text file/anything that shows
that you know programming: I have been programming for a while. I haven'r done any lua in specific, but I'm trying to learn. I made a bukkit plugin here this summer, I'm also working on some other stuff, but have yet to publish anything else. i program for my school's robotics team
I also just made these:
Save as LightsOff:
local tArgs = { ... }
local sSide = tArgs[1]
if not sSide then
error("Usage: LightsOff <side>")
end
redstone.setOutput( sSide, false )
Save as LightsOn:
local tArgs = { ... }
local sSide = tArgs[1]
if not sSide then
error("Usage: LightsOn <side>")
end
redstone.setOutput( sSide, true )
* Additional anything: Sounds like a cool server. I haven't done much stuff with computercraft, but I'm eager to learn
mu-mu-mu-mu-multi fail-fail-fail-fail......(echos)
you dont have to be a good builder at all to go on here and you have to PROVE that you know coding, not just saying 'yes' i am telling you before more comes because you will have to wait a long time for him to see your application again
Age: 18
Programming languages: C/C++, C#, Java, a little Python.
Anything Else: Have never touched Lua until I got the ComputerCraft mod a few days ago. Been doing some editing of programs in Notepad++. Have made a few basic programs such as "Hello World" and some that ask for a password, and verify. I have also dabbled slightly in html and ruby as well, but don't ask me to recall any of it haha.
Also, figured I should add an example of what I did in my Java class last year at college. Third project we had to make a grading organizer application, here is what I got, a very inefficient, but working, .java program.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/** Dialog box name/test calculator
Project 3 -- Layne Bradigan (thats me, Neckername)
*/
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import java.util.Scanner;
import java.text.NumberFormat;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
public class Proj3
{
public static void main(String[] args)
{
String name0;
String first0; // strings for 5 students, sep strings for first and last names.
String last0;
String name1;
String first1;
String last1;
String name2;
String first2;
String last2;
String name3;
String first3;
String last3;
String name4;
String first4;
String last4;
//First student name
name0 = JOptionPane.showInputDialog("Please enter the first student's name in the following format: (first last).");
name0 = name0.trim();
int first0Index0 = 0;
int spaceIndex0 = name0.indexOf(" ");
int last0Index0 = spaceIndex0 + 1;
first0 = name0.substring(0, spaceIndex0);
last0 = name0.substring(last0Index0);
//First student grade
String grade0 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the first student.");
double nGrade0 = java.lang.Integer.parseInt(grade0);
double dGrade0 = (nGrade0 / 150);
double pGrade0 = Math.rint(dGrade0 * 100);
//Second student name
name1 = JOptionPane.showInputDialog("Please enter the second student's name in the following format: (first last).");
name1 = name1.trim();
int first1Index1 = 0;
int spaceIndex1 = name1.indexOf(" ");
int last1Index1 = spaceIndex1 + 1;
first1 = name1.substring(0, spaceIndex1);
last1 = name1.substring(last1Index1);
//Second student grade
String grade1 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the second student.");
double nGrade1 = java.lang.Integer.parseInt(grade1);
double dGrade1 = (nGrade1 / 150);
double pGrade1 = Math.rint(dGrade1 * 100);
//Third student name
name2 = JOptionPane.showInputDialog("Please enter the third student's name in the following format: (first last).");
name2 = name2.trim();
int first2Index2 = 0;
int spaceIndex2 = name2.indexOf(" ");
int last2Index2 = spaceIndex2 + 1;
first2 = name2.substring(0, spaceIndex2);
last2 = name2.substring(last2Index2);
//Third student grade
String grade2 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the third student.");
double nGrade2 = java.lang.Integer.parseInt(grade2);
double dGrade2 = (nGrade2 / 150);
double pGrade2 = Math.rint(dGrade2 * 100);
//Fourth student name
name3 = JOptionPane.showInputDialog("Please enter the fourth student's name in the following format: (first last).");
name3 = name3.trim();
int first3Index3 = 0;
int spaceIndex3 = name3.indexOf(" ");
int last3Index3 = spaceIndex3 + 1;
first3 = name3.substring(0, spaceIndex3);
last3 = name3.substring(last3Index3);
//Fourth student grade
String grade3 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the fourth student.");
double nGrade3 = java.lang.Integer.parseInt(grade3);
double dGrade3 = (nGrade3 / 150);
double pGrade3 = Math.rint(dGrade3 * 100);
//Fifth student name
name4 = JOptionPane.showInputDialog("Please enter the fifth student's name in the following format: (first last).");
name4 = name4.trim();
int first4Index4 = 0;
int spaceIndex4 = name4.indexOf(" ");
int last4Index4 = spaceIndex4 + 1;
first4 = name4.substring(0, spaceIndex4);
last4 = name4.substring(last4Index4);
//Fifth student grade
String grade4 = JOptionPane.showInputDialog ("Please enter the score (out of 150 points) of the fifth student.");
double nGrade4 = java.lang.Integer.parseInt(grade4);
double dGrade4 = (nGrade4 / 150);
double pGrade4 = Math.rint(dGrade4 * 100);
//Class average
double finalG0 = (pGrade0 + pGrade1 + pGrade2 + pGrade3 + pGrade4) / 5;
double finalG1 = Math.rint(finalG0 * 100)/100;
//Average differences
double avDiff0 = Math.rint(finalG1 - pGrade0) * 100;
double avDiff00 = Math.abs(avDiff0);
double avDiff1 = Math.rint(finalG1 - pGrade1) * 100;
double avDiff11 = Math.abs(avDiff1);
double avDiff2 = Math.rint(finalG1 - pGrade2) * 100;
double avDiff22 = Math.abs(avDiff2);
double avDiff3 = Math.rint(finalG1 - pGrade3) * 100;
double avDiff33 = Math.abs(avDiff3);
double avDiff4 = Math.rint(finalG1 - pGrade4) * 100;
double avDiff44 = Math.abs(avDiff4);
//Final Output
String out0 = ("Test Results: " + last0 + ", " + first0 + " got " + pGrade0 + " points on the test. The difference between the class average was " + avDiff00 + " points. " + last1 + ", " + first1 + " got " + pGrade1 + " points on the test. The difference between the class average was " + avDiff11 + " points. " + last2 + ", " + first2 + " got " + pGrade2 + " points on the test. The difference between the class average was " + avDiff22 + " points. " + last3 + ", " + first3 + " got " + pGrade3 + "points on the test. The difference between the class average was " + avDiff33 + " points. " + last4 + ", " + first4 + " got " + pGrade4 + " points on the test. The difference between the class average was " + avDiff44 + " points. The class average = " + finalG1 + " points.");
JOptionPane optionPane = new NarrowOptionPane();
optionPane.setMessage(out0);
optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog(null, "Results");
dialog.setVisible(true);
}
}
/*This code prevents the window from resulting in one line across the screen
by limiting the number of characters a line may contain in the resulting dialog box
*/
class NarrowOptionPane extends JOptionPane {
NarrowOptionPane() {
}
public int getMaxCharactersPerLineCount() {
return 64;
}
}
@Assassin55 there's sadly nothing I can do about it, as I cannot install anti-grief plugins :sad.gif: (computercraft don't support Bukkit)
@ihaveamac The server gets very laggy after a while of playing. I am 99% sure it's COmputerCraft's fault, but I'm constantly looking for a fix.
* Age (minimum 12 years):13
* Screenshot/world save/text file/anything that shows
that you know programming: I know some html, i know just a little lua!
<HTML><Body>
hi!
This is a heading1
This is a heading12
This is a heading123
</body></html>
print ("Your Computer, will now reboot.")
sleep (2)
os.reboot
startup:
print ("Welcome.")
sleep (1)
print ("Loading CraftOS...")
sleep (3)
print ("CraftOS fully initialized!")
* Additional anything: nope.avi
Age (minimum 12 years): 13
Screenshot/world save/text file/anything that shows that you know LUA:
Additional anything: do those count /\?
* Age (minimum 12 years): 13
* Screenshot/world save/text file/anything that shows
that you know programming:
Output: Yes, I know programming, now STFU!
* Additional anything: Please do not take offense to anything my program said to you, it was just a joke.
dimitriye98 and falloutfan101, can you please show me a little more advanced programs?
@Xeonic97 He is now banned.
i cant get on, i think you typed my name wrong? it has 2 ones at the end and in your post its 191 it should be 1911
I absolutely lol'd as hard as i could.
someone could just type programs and see the password :dry.gif:
* Age (minimum 12 years): 14
* Screenshot/world save/text file/anything that shows
that you know programming:
local validChoice = false
local choice = 0
repeat
term.setCursorPos(1,currentLine)
term.clearLine()
term.write(text)
-- read input from user
input = read()
-- convert to number
inputnum = tonumber(input)
-- if string was no number
if inputnum == nil then
validChoice = false
else
-- no floats
choice = math.floor(inputnum)
validChoice = true
if min ~= nil and choice < min then
validChoice = false
end
if max ~= nil and choice > max then
validChoice = false
end
end
until validChoice
return choice
end
local function setColorForKey(key)
local colorStringTable = {}
colorStringTable[1] = {"White", colors.white}
colorStringTable[2] = {"Light gray", colors.lightGray}
colorStringTable[3] = {"Gray", colors.gray}
colorStringTable[4] = {"Black", colors.black}
colorStringTable[5] = {"Yellow", colors.yellow}
colorStringTable[6] = {"Orange", colors.orange}
colorStringTable[7] = {"Red", colors.red}
colorStringTable[8] = {"Pink", colors.pink}
colorStringTable[9] = {"Magenta", colors.magenta}
colorStringTable[10] = {"Purple", colors.purple}
colorStringTable[11] = {"Lime", colors.lime}
colorStringTable[12] = {"Green", colors.green}
colorStringTable[13] = {"Cyan", colors.cyan}
colorStringTable[14] = {"Light blue", colors.lightBlue}
colorStringTable[15] = {"Blue", colors.blue}
colorStringTable[16] = {"Brown", colors.brown}
term.clear()
term.setCursorPos(1,1)
print ("Set color for \"" .. key .. "\":")
print ("")
-- write colors
for i=1,8,1 do
-- make a 2 chars wide string with i
strnum = string.format("%i", i)
if string.len(strnum) == 1 then
strnum = " " .. strnum
end
firstpart = strnum .. " " .. colorStringTable[i][1]
space = string.rep(" ", 13 - string.len(colorStringTable[i][1]))
strnum = string.format("%i", i+8)
if string.len(strnum) == 1 then
strnum = " " .. strnum
end
secondpart = strnum .. " " .. colorStringTable[i+8][1]
print (firstpart .. space .. secondpart)
end
print ("")
choice = readNumber(12, "Choice [1-16]: ", 1, 16)
-- return colorcode for choice
return colorStringTable[choice][2]
end
local function explode(d,p)
local t, ll
t={}
ll=0
if(#p == 1) then return {p} end
while true do
l=string.find(p,d,ll,true) -- find the next d in the string
if l~=nil then -- if "not not" found then..
table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
ll=l+1 -- save just after where we found it for searching next time.
else
table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
break -- Break at end, as it should be, according to the lua manual.
end
end
return t
end
local function setTable(key)
local numelements = 0
table = {}
term.clear()
term.setCursorPos(1,1)
print ("Set table for \"" .. key .. "\":")
print ("")
numelements = readNumber(2, "number of entries [1-16]: ", 1, 16)
for i=1,numelements,1 do
table[i] = setColorForKey(key .. "[" .. string.format("%i",i) .. "]")
end
return table
end
local function savetable(table, filename)
file = fs.open(filename, "w")
for key,value in pairs(table) do
if type(value) == "number" then
file.write(key .. "=" .. string.format("%i", value))
elseif type(value) == "table" then
file.write( key .. "={" )
for subindex,subentry in ipairs(value) do
file.write(string.format("%i", subentry))
if subindex < #value then
file.write(",")
end
end
file.write("}")
end
file.write("\n")
end
file:close()
end
local function loadtable(loadedtable, sPath)
local tLines = {}
local file, error = io.open( sPath, "r" )
local sLine = file:read()
while sLine do
table.insert( tLines, sLine )
sLine = file:read()
end
file:close()
for linenr,line in ipairs(tLines) do
parts = explode("=", line)
if #parts == 2 then
value = 0
if string.sub(parts[2], 0,1) == "{" then
numberstr = string.sub(parts[2], 2, string.len(parts[2])-1)
value = {}
if string.find(numberstr, ",", 1, true) ~= nil then
for a in string.gmatch(numberstr, "([^,]+),?") do
table.insert(value, tonumber(a))
end
else
table.insert(value, tonumber(numberstr))
end
else
value = tonumber(parts[2])
end
loadedtable[ parts[1] ] = value
end
end
end
local function definetable(table)
for key,value in pairs(table) do
if type(value) == "number" then
table[key] = setColorForKey(key)
elseif type(value) == "table" then
table[key] = setTable(key)
end
end
end
function configure(iotable, tablefile, force)
if fs.exists(tablefile) and force ~= true then
loadtable(iotable, tablefile)
else
definetable(iotable)
savetable(iotable, tablefile)
term.write("Wrote new Config. Rebooting in ")
sleep(1)
term.write(" 3 ")
sleep(1)
term.write(" 2 ")
sleep(1)
term.write(" 1 ")
sleep(1)
os.reboot()
end
end
--[[
local tArgs = {...}
local bool_forceNewConfig
-- if we passed "config", force configuration
if #tArgs == 1 and tArgs[1] == "config" then
bool_forceNewConfig = true
else
bool_forceNewConfig = false
end
-- import my program
dofile("configurator")
-- create a table
myBundledIosTable = {}
-- add some keys
-- either define type as number
myBundledIosTable.anInput = 0
-- or as an empty table
myBundledIosTable.someTransposers = {}
myBundledIosTable.someSensors = {}
-- call configure
-- when "configfile" doesn't exist, a gui lets the user configure values
-- saves them to said file and reboots.
-- successive runs of this program will then load the configfile,
-- no user interaction will be needed anymore.
-- by setting "bool_forceNewConfig" to true, a new config can be forced, regardless
-- if "configfile" is present or not
configure(myBundledIosTable, "configfile", bool_forceNewConfig)
-- now we do some stuff
while true do
event, p1, p2 = os.pullEvent()
if event == "redstone" then
-- test our input
inputActive = redstone.testBundledInput("back", myBundledIosTable.anInput)
transposerColors = 0
-- create a selection of all transposers
for i=0,1,#myBundledIosTable.someTransposers do
transposerColors = colors.combine(transposerColors, myBundledIosTable.someTransposers[i])
end
-- pulse above selection for 0.1 seconds
redstone.setBundledOutput("back", transposerColors)
sleep(0.1)
redstone.setBundledOutput("back", 0)
end
end
]]--
* Additional anything: Love computercraft, I know lua quite a lot. I just got computercraf t a week ago. That was my first machine in the video, that's why it's so horrible.
dimitriye98 and falloutfan101, can you please show me a little more advanced programs?
@Xeonic97 He is now banned.
i cant get on, i think you typed my name wrong? it has 2 ones at the end and in your post its 191 it should be 1911
it was not too hard for me to learn basic stuff and play a bit around with it.
I'm still learning and I would love to do that on a server with others who are (most likely)
more advanced than me!
ingame name: johnjonny123
age: 16(since a few days :tongue.gif:)
what i made first was the classic password door:
enter = "enter password"
help = "help"
print("for help type 'help'")
print("for to enter the password type 'enter password'")
instru = read()
if instru == (help) then
sleep(1)
print("'")
print("after the correct password was entered")
sleep(3)
print("'")
print("please walk down the path to your right")
sleep(3)
print("'")
print("do NOT hesitate")
sleep(3)
print("'")
print("at the end of the path is the elevator")
sleep(3)
print("'")
print("once again do NOT hesitate and place yourself in the middle of it!!!")
sleep(6)
print("'")
print("now enter the password")
sleep(5)
print("restart")
os.reboot()
end
if instru == (enter) then
password = read()
end
if password == (escapeword) then
print("!!!!!!!!!")
print("!exactly!")
print("!!!!!!!!!")
sleep(5)
redstone.setOutput("back", true)
sleep(20)
redstone.setOutput("back", false)
else print("that was not correct")
sleep(3)
print("the system will now shutdown for security reasons")
sleep(3)
print("for to try again please start the computer again")
sleep(3)
end
os.shutdown()
And i found a way to prevent people (me, since i did it in singelplayer XD) from doing what they want with the computer
by modifying the startup thing with shell.run("disk/program") and os.shutdown()
now i wrote the "program" on the disk that simply starts another program, for example my password-program . The cool thing about that is that i can control in game which program the computer will be running simply by changing the disk.
If somebody starts the computer and there is no disk with the "program" on it it will shut down.
if somebody knows the command for to restart a program without exit it or running another program please tell me!
Good enough?
My Lua's a bit rusty since it's been some time since I last wrote anything serious using it, but I hope this is good enough.
* Age (minimum 12 years): 12, but I'll be 13 in a month
* Screenshot/world save/text file/anything that shows
that you know programming: I have been programming for a while. I haven'r done any lua in specific, but I'm trying to learn. I made a bukkit plugin here this summer, I'm also working on some other stuff, but have yet to publish anything else. i program for my school's robotics team
I also just made these:
Save as LightsOff:
Save as LightsOn:
* Additional anything: Sounds like a cool server. I haven't done much stuff with computercraft, but I'm eager to learn
Age (minimum 12 years):14
Screenshot: http://s1057.photobucket.com/albums/t392/mrpokeme/
that you know programming:yes
Additional anything: i'm a good builder
mu-mu-mu-mu-multi fail-fail-fail-fail......(echos)
you dont have to be a good builder at all to go on here and you have to PROVE that you know coding, not just saying 'yes' i am telling you before more comes because you will have to wait a long time for him to see your application again
@MrPokeme42 Wow nice code you got there. (sarcastic)
@RonanZer0 can you log on now? I think I fixed it a few days ago, just didn't have the time to post it here.
Still says I'm not whitelisted