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

help bios:367:'end' expected

Started by benoitdu87, 28 October 2015 - 10:51 AM
benoitdu87 #1
Posted 28 October 2015 - 11:51 AM
hello, my problem is that in my program , I must close 'function' in line 35 but if I 'end' , its makes me nil value .
Could you please help me
Thank you

my program:
Spoiler
m=peripheral.wrap("bottom")

m.setTextScale(0.5)
x,y=m.getZise()
print(x..";"..y)


iter=0
text="-=+=-"
items={}
stars={}
starsNbr=150

function registerStars()
stars()
for i=1,starsNbr do
toAdd={}
toAdd["x"]=math.random(1,x)
toAdd["y"]=math.random(1,y)
table.insert(stars,toAdd)
end
end
function forwardStars()
for k,v in pairs(stars) do
stars[k]["x"]=stars[k]["x"]-1
end
for i=1,10 do
toAdd={}
toAdd["x"]=x
toAdd["y"]=math.random(1,y)
if math.random(1,100)>90 then table.insert(stars)
end
end

function drawstars()
for k,v in pairs(stars) do
m.setCursorPos(v,["x"],v["y"])
if math.random(1,100)>70 then m.setTextColor(colors.write)
end
end

function redraw() 
m.clear()
m.setTextColor(colors.gray)
drawnStars()
m.setTextColor(colors.lightgray)
for k,v in pairs(items) do
items[k]["x"]=v["x"]-1
m.setCursorPos(v,["x"],v["y"])
m.write(text)
if v["x"]<0 then table.remove(items,k) end
end 
end 

function addPlot() 
h=math.random(1,y) 
add={} 
add["x"]=x
add["y"]=h
table.insert(items,add)
end

registerStars() 
while true do
iter=iter+1
redraw()
os.sleep(0.05)
if iter % 14==0 then addPlot() end
if iter % 20==0 then forwardStars() end
end
Edited by
Bomb Bloke #2
Posted 28 October 2015 - 01:19 PM
There are two lines in there, each beginning with "if math.random…", that seem to be missing their "end"s.