Forum

> > CS2D > Scripts > About Tile
Forums overviewCS2D overview Scripts overviewLog in to reply

English About Tile

3 replies
To the start Previous 1 Next To the start

old About Tile

kalis
User Off Offline

Quote
Hello guys
today i create a topic to know :
- How to spawn a npc in tile

Ok , example :
x,y = tilex or tiley of tile type
1
2
3
if tile(x,y,"walkable") == 102 then
 -do
end


How it is happen?

old Re: About Tile

Jynxxx
User Off Offline

Quote
It goes like...
1
2
3
if tile(x,y,"walkable") == true then
	--do
end

old Re: About Tile

Infinite Rain
Reviewer Off Offline

Quote
1
2
3
4
5
x, y, type, rot = 50, 50, 1, 0 -- chnage

if tile(x, y, 'walkable') then
	parse('spawnnpc '.. type ..' '.. x ..' '.. y ..' '.. rot)
end

NPC types:
1 - zombie
2 - headcrab
3 - snark
4 - vortigaunt
5 - soldier

old Re: About Tile

kalis
User Off Offline

Quote
ok thank alot
and i have a problem more !

my lua
1
2
3
grass.x = {}
grass.y = {}
grass.img = {}
1
2
3
4
5
6
7
addhook("second","_spawn")
function _spawn()
for i = 1,5 do
	grass.x[i] = math.random(1,30)
	grass.y[i] = math.random(1,30)
	grass.img[i] = image('gfx/city_kalis/grass.bmp',3,2,1)
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("attack","cut_grass")
function cut_grass(id)		
		local x = player(id,"x")
		local y = player(id,"y")
		if w == 50 then
			for i = 1,5 do
				if grass.x[i] > 0 and grass.y[i] > 0 then
					local dist = math.sqrt((grass.x[i]-x)^2+(grass.y[i]-y)^2)
					if dist < 30 then
						if grass.img[i] ~= nil then
							grass.x[i] = 0
							grass.y[i] = 0
							freeimage(grass.img[i])
							parse("sv_msg2 "..id.." nice work")
						end

					end

				end
			end
		end

end

Problem is :
grass.x[i],grass.y[i],grass.img[i] !
.... !
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview