Forum
CS2D Scripts Creating npcCreating npc
6 replies 1
2.
1
imagecolor(imageid,red,green,blue)
TheKilledDeath's Lua tutorial
Programming in Lua - official guide
Lua reference manual
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
npc={} npc[1]={name="Robert",x=27,y=27,msg="Can you help me?",rot=120,img=1} addhook("second","spawnimg") function spawnimg(id) for a=1,#npc do npc[a].px=npc[a].x*32+16 npc[a].py=npc[a].y*32+16 npc[a].sprite=image("gfx/npc"..npc[a].img..".png",npc[a].px,npc[a].py,1) end end addhook("say","wordsay") function wordsay(id,t) for a=1,#npc do if (player(id,"tilex")>=npc[a].x-1 and player(id,"tilex")<=npc[a].x+1 and player(id,"tiley")>=npc[a].y-1 and player(id,"tiley")<=npc[a].y+1) then if t=="hi" or t=="hello" then msg2(id,""..npc[a].name..":"..npc[a].msg.."") end end end end
say hi front of NPCs after NPCs answer you
xSkyLordx has written
say hi front of NPCs after NPCs answer you
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
npc={} npc[1]={name="Robert",x=27,y=27,msg="Can you help me?",rot=120,img=1} addhook("second","spawnimg") function spawnimg(id) for a=1,#npc do npc[a].px=npc[a].x*32+16 npc[a].py=npc[a].y*32+16 npc[a].sprite=image("gfx/npc"..npc[a].img..".png",npc[a].px,npc[a].py,1) end end addhook("say","wordsay") function wordsay(id,t) for a=1,#npc do if (player(id,"tilex")>=npc[a].x-1 and player(id,"tilex")<=npc[a].x+1 and player(id,"tiley")>=npc[a].y-1 and player(id,"tiley")<=npc[a].y+1) then if t=="hi" or t=="hello" then msg2(id,""..npc[a].name..":"..npc[a].msg.."") end end end end
say hi front of NPCs after NPCs answer you
*FACEPALM*
I think he meant NPC as mobs
1