Grim Reaper, on 07 March 2013 - 06:05 PM, said:
[CC]Code Cleanup
#41
Posted 07 March 2013 - 06:41 PM
#42
Posted 08 March 2013 - 03:40 AM
SuicidalSTDz, on 07 March 2013 - 06:41 PM, said:
Grim Reaper, on 07 March 2013 - 06:05 PM, said:
I agree
#43
Posted 18 March 2013 - 01:57 AM
SuicidalSTDz, on 07 March 2013 - 03:55 PM, said:
-snip-
local open = io.open
local spam = "SPAM!"
local handle = open("test", "w")
local data = {}
for i = 1,100 do
table.insert(data,spam.."THIS IS SPAM!")
end
handle:write(textutils.serialize(data))
handle:close()
local open = io.open("test", "r")
local read = open:read()
local dataTable = textutils.unserialize(read)
open:close()
for k,v in ipairs(dataTable) do
print(v)
end
Missing quotation marks around w and r in openMissing quotation mark to close string THIS IS SPAM
Missing do closer after both for statements
Wrong type of integrator (ipairs not pairs)
Ehhh....y u no make it simpler D:< ... jk
Mine
NOTE: It's purpose is to set monitorSide to the side a monitor is attached OR "none" if none. Keep that in mind.
local sides = {"left, "right", "top", "bottom", "front" "back}
local monitorSide = "none"
function check(side)
if peripheral.getType(side) ~= "monitor" then monitorSide = side end
end
for i, v in pairs(sides) then
check(v)
end
#44
Posted 26 March 2013 - 08:57 AM
Smiley43210, on 18 March 2013 - 01:57 AM, said:
local sides = {"left, "right", "top", "bottom", "front" "back}
local monitorSide = "none"
function check(side)
if peripheral.getType(side) ~= "monitor" then monitorSide = side end
end
for i, v in pairs(sides) then
check(v)
end
local sides = {"left", "right", "top", "bottom", "front", "back"}
local monitorSide = "none"
function check(side)
if peripheral.getType(side) == "monitor" then monitorSide = side end
end
for i, v in ipairs(sides) then
check(v)
end
- Added closing quotes on "left" and "back"
- Added comma to separate "front" and "back"
- Changed ~= to ==
- Changed pairs to ipairs
My code:
local function() dostuff
locol numbers = {}
local words = {one = 1, ten = 10, one hundred = 100, one thousand = 1000)
for [i = 1 to 1 000] do
if [i = 10 OR (i < 500 AND i > 300) ] do
numbers[i] = Math:random(1, i)
-[[
else
numbers[i] = -i
end
]]
end
local number = 0
while [number < 1000] do
for k,v in ipairs(words) do
if [numbers[number] = v] do
term.print k
end
end
end
return number[10] + numbers[400]
end
#45
Posted 27 March 2013 - 01:43 AM
term.write(Tro)
while true do
term.write(lo)
end
__ This is something annoying
--{{
Haha
}}--
lololol
hehehe
blablabla
wowowo
--[[ Madness! ]]--
#46
Posted 28 March 2013 - 05:45 AM
local monitor=nil
for i,side in ipairs( peripheral.getNames() ) do
if peripheral.getType( side ) == "monitor" then
monitor = side
break
end
end
#47
Posted 28 March 2013 - 02:47 PM
#49
Posted 29 March 2013 - 02:08 AM
Meh, I was tired.
#51
#52
Posted 30 March 2013 - 07:20 PM
#54
Posted 06 April 2013 - 06:46 AM
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString,"sample"); print(indexOfSample)
#55
Posted 06 April 2013 - 07:06 AM
diegodan1893, on 06 April 2013 - 06:46 AM, said:
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString,"sample"); print(indexOfSample)
Only other thing I could think of was this:
local testString = "This is a sample string"; local s,e = string.find(testString,"sample"); print(testString:sub(s, e))Or this:
local testString = "This is a sample string"; local testSubString = string.sub(testString,5) local s,e = string.find(testSubString,"sample"); print(testString:sub(s, e))
#56
Posted 06 April 2013 - 07:13 AM
thesbros, on 06 April 2013 - 07:06 AM, said:
diegodan1893, on 06 April 2013 - 06:46 AM, said:
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString,"sample"); print(indexOfSample)
Only other thing I could think of was this:
local testString = "This is a sample string"; local s,e = string.find(testString,"sample"); print(testString:sub(s, e))
#57
Posted 06 April 2013 - 07:15 AM
diegodan1893, on 06 April 2013 - 07:13 AM, said:
local testString = "This is a sample string"; local testSubString = string.sub(testString,5); local indexOfSample = string.find(testSubString.."","sample"); print(indexOfSample)(can't test it since I don't have access to Minecraft right now)
#58
Posted 04 July 2013 - 09:18 AM
counterVar == 0
while true do
countervar = counterVar+1
os.PullEvent("Redstone")
For i = 1,counterVar
For j = 1, i
term.write("*')
end
Term.write("\newline");
end
term.write("\newline")
#59
Posted 04 July 2013 - 12:47 PM
Xyexs, on 04 July 2013 - 09:18 AM, said:
counterVar == 0
while true do
countervar = counterVar+1
os.PullEvent("Redstone")
For i = 1,counterVar
For j = 1, i
term.write("*')
end
Term.write("\newline");
end
term.write("\newline")
counterVar = 0
while true do
counterVar = counterVar+1
os.pullEvent("redstone")
for i = 1,counterVar do
for j = 1, i do
write("*")
end
write("\n");
end
write("\n")
end
- == instead of = in first line- some fixes because Lua is case-sensitive
- there were no do's after the for statements
- you use " to open a string and ' to close it
- "print("\newline")" would print "
ewline"
- there was a missing end at the end
Edit: I missed that term.write() can't print \n
#60
Posted 04 July 2013 - 04:19 PM
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











