### Author Topic: Fog  (Read 4710 times)

#### Cosmo

• Guest
##### Fog
« on: February 06, 2014, 11:12:40 am »
Hello,

A little bit fog.
Code: [Select]
`--' by peter wirbelauer.function rand(minZahl,maxZahl)   maxZahl= (maxZahl-minZahl)   return int(rnd()*maxZahl+minZahl)endfunction sprite(id,x,y,w,h,fx)   drawimage(w*fx,0,w,h,x,y,id)endscreen(800,600,0,"fog")backcolor(0,0,0)setframetimer(200)local i,t,xres,yres,u,fz,h,w = 0,0,800,600,0,0,0,0local cloudx={}local cloudy={}local clouds={}w = screenwidth() /2h = screenheight()/2u = loadimage("png/ufostrip.png")for i=1,250 do    cloudx[i]=rand(1,xres-2)    cloudy[i]=rand(1,yres-2)    clouds[i]=rand(1,4)endfunction move_clouds()  for i=1,250 do      alphachannel(35)      color(200,200,200)      fillcircle(cloudx[i],cloudy[i],90)      cloudx[i] = cloudx[i]+clouds[i]      if cloudx[i] > xres+128 then         cloudx[i] = -128         cloudy[i] = rand(1,yres -2)         clouds[i] = rand(1,4)      end  endendrepeatt=getkey()cls()alphachannel(255)sprite(u,w,h,199,85,fz)move_clouds()fz=fz+1if fz==8 then fz=0;endredraw()until t==27closewindow()`
« Last Edit: February 06, 2014, 11:33:33 am by Cosmo »

#### Cosmo

• Guest
##### Re: Fog
« Reply #1 on: February 07, 2014, 11:59:01 am »
Hello,

Another idea.

Code: [Select]
`screen(640,480,0,"Jelly")setframetimer(60)backcolor(0,0,200)local frames,index,n,i = 1,0,60,0local mx={}local my={}for i=1,60 do    mx[60]=0    my[60]=0endrepeatk=getkey()clearscreen()alphachannel(60)mx[frames] = mousex()-30my[frames] = mousey()-30for i=1,n do    index = math.fmod(frames+i,60)    color(240,255,255)    ellipse(mx[index],my[index],i,i)endframes=frames +1if frames==60 then frames=1; endsync()until k==27closewindow()     `
« Last Edit: February 08, 2014, 12:38:30 pm by Cosmo »

#### GEEK

• Guest
##### Re: Fog
« Reply #2 on: February 07, 2014, 04:15:48 pm »
lua:21: attempt to call field 'mod' (a nil value)

try this: index = math.fmod(frames+i,60)
« Last Edit: February 07, 2014, 04:22:04 pm by GEEK »

#### Cosmo

• Guest
##### Re: Fog
« Reply #3 on: February 07, 2014, 05:27:33 pm »
Hi Geek,

Quote
lua:21: attempt to call field 'mod' (a nil value)

What lua:21 ?  Is running here!  No error, no crash.
I use lua 5.1 and what have you ?

#### Bereb

• Guest
##### Re: Fog
« Reply #4 on: February 07, 2014, 05:43:50 pm »
Quote
lua:21: attempt to call field 'mod' (a nil value)

What lua:21 ?  Is running here!  No error, no crash.
I use lua 5.1 and what have you ?

lua:21 is the line number where  occured the error (same on my computer)
As GEEK wrote, math.fmod() corrects the problem... However I think this function isn't in Lua 5.1 but in Lua 5.2 (I'm not sure), and EGSL 1.6.0  is built with Lua 5.2

Correction: math.mod() doesn't exist either in Lua 5.1, it's math.fmod(). But there is also an operator % which can be usefull:
Code: [Select]
`index = (frames+i) % 60`
« Last Edit: February 07, 2014, 06:02:54 pm by Bereb »

#### Cosmo

• Guest
##### Re: Fog
« Reply #5 on: February 07, 2014, 08:47:39 pm »
Hi Bereb,

I have Lua5.1.dll here!  math.mod doesn't make trouble.
Jelly runs fine here with Windows7.

When it would not run, I would not put it to the forum!
« Last Edit: February 07, 2014, 11:07:56 pm by Cosmo »

#### GEEK

• Guest
##### Re: Fog
« Reply #6 on: February 07, 2014, 11:37:55 pm »
I use the standart EGSL IDE and maybe that's why we got this problem and you don't?
I use "lua52.dll"

#### Cosmo

• Guest
##### Re: Fog
« Reply #7 on: February 08, 2014, 11:18:42 am »
Hi Geek,

where did you get it?  (lua52.dll)

#### Tomaaz

• Guest
##### Re: Fog
« Reply #8 on: February 08, 2014, 11:34:26 am »
where did you get it?  (lua52.dll)

EGSL 1.6 uses lua52, EGSL 1.5 - lua51.

#### Cosmo

• Guest
##### Re: Fog
« Reply #9 on: February 08, 2014, 12:45:17 pm »
Thanks Tomaaz,