Forum

> > CS2D > Scripts > projectile freeimage
Forums overviewCS2D overview Scripts overviewLog in to reply

English projectile freeimage

4 replies
To the start Previous 1 Next To the start

old projectile freeimage

En-Kay
User Off Offline

Quote
Ok so this script creates an image on projectile impact which is removed after 450ms,but the problem is when another projectile explodes at the same time,only one image is removed.

here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
impact = {}

addhook("projectile","arcane")
function arcane (id,weapon,x,y)

	if (weapon==48) then
		impact[id] = image("gfx/sprites/wave.bmp" ,x,y,1)
		imageblend (impact[id],1)
		imagecolor (impact[id],75,75,255)
		tween_scale (impact[id],450,5.0,5.0)
		timer(450,"removeimpact")

		function removeimpact()
		freeimage (impact[id])
		end
	end
end

old Re: projectile freeimage

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
impact = {}
impact.init = 0

addhook("projectile","arcane")
function arcane (id,weapon,x,y)
	function removeimpact(i)
		freeimage (impact[i])
		impact[i] = nil
	end
	if (weapon==48) then
		impact.init = impact.init + 1
		local img = impact.init
		impact[img] = image( "gfx/sprites/wave.bmp", x, y, 1 )
		  imageblend( impact[img], 1 )
		  imagecolor( impact[img], 75, 75, 255 )
		  tween_scale( impact[img], 450, 5.0, 5.0 )
		timer(450, "removeimpact", img)
	end
end

old Re: projectile freeimage

En-Kay
User Off Offline

Quote
This error pops out:

1
LUA ERROR: sys/lua/core/core.lua:31: bad argument #1 to 'freeimage' (number expected, got nil)

old Re: projectile freeimage

En-Kay
User Off Offline

Quote
Ok guys i've fixed it. Just added :

1
freeimage (impact[tonumber(id)])

Anyway, thanks for your help. Appreciate it.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview