English Spawn NPC for tile

5 replies
Goto Page
To the start Previous 1 Next To the start
11.06.19 12:09:40 am
Up
Sagaiwa
User
Offline Off
I want spawn zombie only if tile frame #1.
Please help

Code:
1
2
3
4
5
function second_hook()

parse("spawnnpc 1 "..math.random(zombix1,zombix2).." "..math.random(zombiy1,zombiy2).."")

end
11.06.19 12:22:53 am
Up
Goo
User
Offline Off
Loop through every tile on the map and check if it's frame is #1.
11.06.19 12:32:20 am
Up
Sagaiwa
User
Offline Off
I want code

if tilex,tiley == tilesetframe#1 then spawn npc

How can I do this?
11.06.19 12:35:22 am
Up
panteon00
User
Offline Off
you can fetch the map size with the cs2d lua cmd map and the tile frame with cs2d lua cmd tile.

something like this:
Code:
1
2
3
4
5
6
7
8
9
function second_hook()
     for x=0, map("xsize") do
          for y=0, map("ysize") do
               if tile(x,y,"frame")==1 then
                    parse("spawnnpc 1 "..math.random(zombix1,zombix2).." "..math.random(zombiy1,zombiy2).."")
               end
          end
     end
end
loading...
11.06.19 12:46:51 am
Up
Sagaiwa
User
Offline Off
@user panteon00: Thank you bro!
To the start Previous 1 Next To the start