[CC]Code Cleanup
#161
Posted 06 March 2015 - 07:03 AM
#162
Posted 06 March 2015 - 09:02 AM
local hugs = "YEAH" -- defined hugs
If hugs == nil then
print("You dun wunt hugs?") -- fixed prinl
elseif Hugs ~= nil then -- changed if to elseif
print("YUS, HUGGERS") --fixed bracket/parenthesis and add quotation
endBugs!
Pie =
If Pie = Yes then
print("YEAH! PIE IS GREAT!")
eles Pie = No then
print(Get out of my sight)
dne
Edit: God I hate the color bug...
Edited by cptdeath58, 06 March 2015 - 09:10 AM.
#163
Posted 08 March 2015 - 08:01 PM
Pie = --no value here for initulise
If Pie = Yes then --unless Yes is a var, then should be "Yes"
print("YEAH! PIE IS GREAT!") --just to have a comment on every line
eles Pie = No then --see comment about yes --else, not eles
print(Get out of my sight) --need quote marks here
dne --should be end
--language = lua
while true doh
{
print("Loop ".."= "..loop);
loop++;
}
end;
Edited by Lupus590, 08 March 2015 - 08:05 PM.
#164
Posted 08 March 2015 - 08:48 PM
while true do
print("Loop ".."= "..loop);
loop = loop + 1;
end;
- No braces
- do not doh
- loop = loop + 1 not loop++
- "Loop " .. "= " could be combined into one. I don't think Lua implements constant folding...
- Loop isn't defined.
-- Lets calculate Fibonacci numbers! do local a, b = 1 fur i = 0, 100, -1 do a, b = a, a + b end for end print(a)
There are ~6 bugs, maybe more maybe less.
Edited by SquidDev, 08 March 2015 - 08:51 PM.
#165
Posted 13 August 2015 - 12:23 PM
--Lets calculate Fibonacci numbers! do a, b =1,1 for i = 0,100 do a,b = a, a + b b,a = b, a + b end end print(a) 1. the fur loop 2. the for after the end 3. b is not defined 4. The for loop will never end 5. var called 'a' is not changingMy code:
--This code downloads a file and saves its first line into a log (should)
local a = http.get("a random url")
local b = fs.open("log.txt")
b.writeLine(a.readLine())
5 + 1 bugsEDIT: the url is NOT a bug
Edited by Konlab, 13 August 2015 - 12:27 PM.
#166
Posted 21 August 2015 - 09:30 AM
Konlab, on 13 August 2015 - 12:23 PM, said:
My code:
--This code downloads a file and saves its first line into a log (should)
local a = http.get("a random url")
local b = fs.open("log.txt")
b.writeLine(a.readLine())
5 + 1 bugsEDIT: the url is NOT a bug
well, i haven't done lua for a while. here i go.
local a = http.get("url")
local b = fs.open("log.txt","w") --choose mode
b.write(a.readAll()) --readLine doesn't exist
b.close() --you forgot to close it after
--your gonna have to write the whole thing. deal with it.
i think thats it?
#167
Posted 21 August 2015 - 04:29 PM
Wait_, on 21 August 2015 - 09:30 AM, said:
Konlab, on 13 August 2015 - 12:23 PM, said:
My code:
--This code downloads a file and saves its first line into a log (should)
local a = http.get("a random url")
local b = fs.open("log.txt")
b.writeLine(a.readLine())
5 + 1 bugsEDIT: the url is NOT a bug
well, i haven't done lua for a while. here i go.
local a = http.get("url")
local b = fs.open("log.txt","w") --choose mode
b.write(a.readAll()) --readLine doesn't exist
b.close() --you forgot to close it after
--your gonna have to write the whole thing. deal with it.
i think thats it?
local t = {a.readAll():gsub("(.+)\n.+")}
b.write(t[1])
And I failed another time...
Edited by H4X0RZ, 22 August 2015 - 11:17 PM.
#168
Posted 28 February 2016 - 12:11 AM
locla variable = os.pullEvent("redstone")
if variable == true or variable == false then
if variable == true then
rs,setAnanlogOutput(15)
else
rs,setAnanlogOutput(0)
end
end
At least 6 bugs and sloppy code to boot
#169
Posted 28 February 2016 - 10:26 AM
local variable = os.pullEvent("redstone")
if variable == true then
rs.setAnanlogOutput(15)
else
rs.setAnanlogOutput(0)
end
local event = {corotine.yielld("anything")}
if evnet[1] == "wow" then
print(wow)
end
Edited by Creator, 28 February 2016 - 03:35 PM.
#171
Posted 28 February 2016 - 05:20 PM
os.pullEvent("redstone")
[color=black][font=monospace, Courier]for k, v in pairs(redstone.getSides()) do[/font][/color]
if rs.getInput(v) then
rs.setOutput(true)
break
else
rs.setOutput(false)
end
end
local, not locla!
The redstone event doesn't return anything, and the first return value would be "redstone".
You don't need to check if something is true or false, and you don't need to == true.
You don't need analog output if you're only going to set it to max or min.
Dot, not comma!
Analog is not spelt like that.
lolcal vec == vetcor\nil{#4 ;%6 :$2]
locla n == ('x´ .´y` ;"z´)
f0ur u == 9 .7 ;-1 dO
widowns,turm:pirnt[vce{m(10 - u]}]
amd
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











