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
2
3
if tile(x,y,"walkable") == 102 then -do end
How it is happen?
if tile(x,y,"walkable") == 102 then -do end
if tile(x,y,"walkable") == true then 	--do end
x, y, type, rot = 50, 50, 1, 0 -- chnage if tile(x, y, 'walkable') then 	parse('spawnnpc '.. type ..' '.. x ..' '.. y ..' '.. rot) end
grass.x = {} grass.y = {} grass.img = {}
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
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