Lua Error Npc lua
3 replies



16.10.13 01:37:54 pm
LUA ERROR: sys/lua/npc systen.lua:59: '=' expected near 'if'
help? ;3
Code 

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
npcx=initArray(32)
npcy=initArray(32)
npcid=initArray(32)
npcimg=initArray(32)
npcrot=initArray(32)
addhook("serveraction","npc_serveraction")
function npc_serveraction(id,b)
if (b==4) then
npc_menu_npc(id)
end
end
addhook("menu","npc_menu")
function npc_menu(id,t,b)
if (t=="NPC NPC Menu") then
if (b==1 and npcx[id]==0 and npcy[id]==0) then
npc_create(id,player(id,"x"),player(id,"y"),270,"gfx/weiwen/npc1.png")
npc_menu_npc(id)
end
if (b==2) then
npc_menu_move_npc(id)
end
if (b==3) then
npcx[id]=player(id,"x")
npcy[id]=player(id,"y")
npc_refresh(id)
npc_menu_npc(id)
end
if (b==4) then
npc_menu_change_npc(id)
end
end
if (t=="NPC Move NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npc_move_left(id)
npc_menu_move_npc(id)
end
if (b==3) then
npc_move_right(id)
npc_menu_move_npc(id)
end
if (b==4) then
npc_move_up(id)
npc_menu_move_npc(id)
end
if (b==5) then
npc_move_down(id)
npc_menu_move_npc(id)
end
end
if (t=="NPC Change NPC Menu") then
if (b==1) then
npc_menu_npc(id)
endnpc
if (b==2) then
npcimg[id]="gfx/weiwen/npc1.png"
npc_refresh(id)
end
if (b==3) then
npcimg[id]="gfx/weiwen/npc2.png"
npc_refresh(id)
end
if (b==4) then
npcimg[id]="gfx/weiwen/npc3.png"
npc_refresh(id)
end
end
-----------------------------------------[ Menu NPC ]-----------------------------------------
function npc_menu_npc(id)
menu(id,"NPC Menu,Create your NPC,Move your NPC,Set position of NPC to your,Set image of your NPC")
end
function npc_menu_change_npc(id)
menu(id,"NPC Change NPC Menu,<- Back,NPC 1,NPC 2,NPC 3")
end
function npc_menu_move_npc(id)
menu(id,"NPC Move NPC Menu,<- Back,Move Left,Move Right,Move Up,Move Down")
end
function npc_refresh(id)
freeimage(npcid[id])
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
imagepos(npcid[id],npcx[id],npcy[id],npcrot[id])
end
function npc_rotate(id,deg)
npcrot[id]=deg
npc_refresh(id)
end
function npc_create(id,x,y,rot,img)
npcx[id]=x
npcy[id]=y
npcrot[id]=rot
npcimg[id]=img
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
npc_refresh(id)
end
function npc_move(id,x,y)
npcx[id]=npcx[id]+x
npcy[id]=npcy[id]+y
npc_refresh(id)
end
function npc_move_up(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,-pixels)
npc_rotate(id,0)
end
function npc_move_down(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,pixels)
npc_rotate(id,180)
end
function npc_move_left(id,pixels)
if not pixels then pixels=16 end
npc_move(id,-pixels,0)
npc_rotate(id,270)
end
function npc_move_right(id,pixels)
if not pixels then pixels=16 end
npc_move(id,pixels,0)
npc_rotate(id,90)
end
npcy=initArray(32)
npcid=initArray(32)
npcimg=initArray(32)
npcrot=initArray(32)
addhook("serveraction","npc_serveraction")
function npc_serveraction(id,b)
if (b==4) then
npc_menu_npc(id)
end
end
addhook("menu","npc_menu")
function npc_menu(id,t,b)
if (t=="NPC NPC Menu") then
if (b==1 and npcx[id]==0 and npcy[id]==0) then
npc_create(id,player(id,"x"),player(id,"y"),270,"gfx/weiwen/npc1.png")
npc_menu_npc(id)
end
if (b==2) then
npc_menu_move_npc(id)
end
if (b==3) then
npcx[id]=player(id,"x")
npcy[id]=player(id,"y")
npc_refresh(id)
npc_menu_npc(id)
end
if (b==4) then
npc_menu_change_npc(id)
end
end
if (t=="NPC Move NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npc_move_left(id)
npc_menu_move_npc(id)
end
if (b==3) then
npc_move_right(id)
npc_menu_move_npc(id)
end
if (b==4) then
npc_move_up(id)
npc_menu_move_npc(id)
end
if (b==5) then
npc_move_down(id)
npc_menu_move_npc(id)
end
end
if (t=="NPC Change NPC Menu") then
if (b==1) then
npc_menu_npc(id)
endnpc
if (b==2) then
npcimg[id]="gfx/weiwen/npc1.png"
npc_refresh(id)
end
if (b==3) then
npcimg[id]="gfx/weiwen/npc2.png"
npc_refresh(id)
end
if (b==4) then
npcimg[id]="gfx/weiwen/npc3.png"
npc_refresh(id)
end
end
-----------------------------------------[ Menu NPC ]-----------------------------------------
function npc_menu_npc(id)
menu(id,"NPC Menu,Create your NPC,Move your NPC,Set position of NPC to your,Set image of your NPC")
end
function npc_menu_change_npc(id)
menu(id,"NPC Change NPC Menu,<- Back,NPC 1,NPC 2,NPC 3")
end
function npc_menu_move_npc(id)
menu(id,"NPC Move NPC Menu,<- Back,Move Left,Move Right,Move Up,Move Down")
end
function npc_refresh(id)
freeimage(npcid[id])
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
imagepos(npcid[id],npcx[id],npcy[id],npcrot[id])
end
function npc_rotate(id,deg)
npcrot[id]=deg
npc_refresh(id)
end
function npc_create(id,x,y,rot,img)
npcx[id]=x
npcy[id]=y
npcrot[id]=rot
npcimg[id]=img
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
npc_refresh(id)
end
function npc_move(id,x,y)
npcx[id]=npcx[id]+x
npcy[id]=npcy[id]+y
npc_refresh(id)
end
function npc_move_up(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,-pixels)
npc_rotate(id,0)
end
function npc_move_down(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,pixels)
npc_rotate(id,180)
end
function npc_move_left(id,pixels)
if not pixels then pixels=16 end
npc_move(id,-pixels,0)
npc_rotate(id,270)
end
function npc_move_right(id,pixels)
if not pixels then pixels=16 end
npc_move(id,pixels,0)
npc_rotate(id,90)
end
help? ;3
Admin/mod comment:
Use tag more for long codes /
Line 58
is
I believe.
Always check line before and after, if you can't find the error in given line.
Code:
1
endnpc
is
Code:
1
end
I believe.
Always check line before and after, if you can't find the error in given line.
16.10.13 01:59:28 pm
thx
now I have another problem
LUA ERROR: sys/lua/npc systen.lua:1: attempt to call global 'initArray' (a nil
now I have another problem
LUA ERROR: sys/lua/npc systen.lua:1: attempt to call global 'initArray' (a nil
Code 

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
npcx=initArray(32)
npcy=initArray(32)
npcid=initArray(32)
npcimg=initArray(32)
npcrot=initArray(32)
addhook("serveraction","npc_serveraction")
function npc_serveraction(id,b)
if (b==4) then
npc_menu_npc(id)
end
end
addhook("menu","npc_menu")
function npc_menu(id,t,b)
if (t=="NPC NPC Menu") then
if (b==1 and npcx[id]==0 and npcy[id]==0) then
npc_create(id,player(id,"x"),player(id,"y"),270,"gfx/weiwen/npc1.png")
npc_menu_npc(id)
end
if (b==2) then
npc_menu_move_npc(id)
end
if (b==3) then
npcx[id]=player(id,"x")
npcy[id]=player(id,"y")
npc_refresh(id)
npc_menu_npc(id)
end
if (b==4) then
npc_menu_change_npc(id)
end
end
if (t=="NPC Move NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npc_move_left(id)
npc_menu_move_npc(id)
end
if (b==3) then
npc_move_right(id)
npc_menu_move_npc(id)
end
if (b==4) then
npc_move_up(id)
npc_menu_move_npc(id)
end
if (b==5) then
npc_move_down(id)
npc_menu_move_npc(id)
end
end
if (t=="NPC Change NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npcimg[id]="gfx/weiwen/npc1.png"
npc_refresh(id)
end
if (b==3) then
npcimg[id]="gfx/weiwen/npc2.png"
npc_refresh(id)
end
if (b==4) then
npcimg[id]="gfx/weiwen/npc3.png"
npc_refresh(id)
end
end
-----------------------------------------[ Menu NPC ]-----------------------------------------
function npc_menu_npc(id)
menu(id,"NPC Menu,Create your NPC,Move your NPC,Set position of NPC to your,Set image of your NPC")
end
function npc_menu_change_npc(id)
menu(id,"NPC Change NPC Menu,<- Back,NPC 1,NPC 2,NPC 3")
end
function npc_menu_move_npc(id)
menu(id,"NPC Move NPC Menu,<- Back,Move Left,Move Right,Move Up,Move Down")
end
function npc_refresh(id)
freeimage(npcid[id])
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
imagepos(npcid[id],npcx[id],npcy[id],npcrot[id])
end
function npc_rotate(id,deg)
npcrot[id]=deg
npc_refresh(id)
end
function npc_create(id,x,y,rot,img)
npcx[id]=x
npcy[id]=y
npcrot[id]=rot
npcimg[id]=img
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
npc_refresh(id)
end
function npc_move(id,x,y)
npcx[id]=npcx[id]+x
npcy[id]=npcy[id]+y
npc_refresh(id)
end
function npc_move_up(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,-pixels)
npc_rotate(id,0)
end
function npc_move_down(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,pixels)
npc_rotate(id,180)
end
function npc_move_left(id,pixels)
if not pixels then pixels=16 end
npc_move(id,-pixels,0)
npc_rotate(id,270)
end
function npc_move_right(id,pixels)
if not pixels then pixels=16 end
npc_move(id,pixels,0)
npc_rotate(id,90)
end
end
npcy=initArray(32)
npcid=initArray(32)
npcimg=initArray(32)
npcrot=initArray(32)
addhook("serveraction","npc_serveraction")
function npc_serveraction(id,b)
if (b==4) then
npc_menu_npc(id)
end
end
addhook("menu","npc_menu")
function npc_menu(id,t,b)
if (t=="NPC NPC Menu") then
if (b==1 and npcx[id]==0 and npcy[id]==0) then
npc_create(id,player(id,"x"),player(id,"y"),270,"gfx/weiwen/npc1.png")
npc_menu_npc(id)
end
if (b==2) then
npc_menu_move_npc(id)
end
if (b==3) then
npcx[id]=player(id,"x")
npcy[id]=player(id,"y")
npc_refresh(id)
npc_menu_npc(id)
end
if (b==4) then
npc_menu_change_npc(id)
end
end
if (t=="NPC Move NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npc_move_left(id)
npc_menu_move_npc(id)
end
if (b==3) then
npc_move_right(id)
npc_menu_move_npc(id)
end
if (b==4) then
npc_move_up(id)
npc_menu_move_npc(id)
end
if (b==5) then
npc_move_down(id)
npc_menu_move_npc(id)
end
end
if (t=="NPC Change NPC Menu") then
if (b==1) then
npc_menu_npc(id)
end
if (b==2) then
npcimg[id]="gfx/weiwen/npc1.png"
npc_refresh(id)
end
if (b==3) then
npcimg[id]="gfx/weiwen/npc2.png"
npc_refresh(id)
end
if (b==4) then
npcimg[id]="gfx/weiwen/npc3.png"
npc_refresh(id)
end
end
-----------------------------------------[ Menu NPC ]-----------------------------------------
function npc_menu_npc(id)
menu(id,"NPC Menu,Create your NPC,Move your NPC,Set position of NPC to your,Set image of your NPC")
end
function npc_menu_change_npc(id)
menu(id,"NPC Change NPC Menu,<- Back,NPC 1,NPC 2,NPC 3")
end
function npc_menu_move_npc(id)
menu(id,"NPC Move NPC Menu,<- Back,Move Left,Move Right,Move Up,Move Down")
end
function npc_refresh(id)
freeimage(npcid[id])
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
imagepos(npcid[id],npcx[id],npcy[id],npcrot[id])
end
function npc_rotate(id,deg)
npcrot[id]=deg
npc_refresh(id)
end
function npc_create(id,x,y,rot,img)
npcx[id]=x
npcy[id]=y
npcrot[id]=rot
npcimg[id]=img
npcid[id]=image(npcimg[id],npcx[id],npcy[id],1)
npc_refresh(id)
end
function npc_move(id,x,y)
npcx[id]=npcx[id]+x
npcy[id]=npcy[id]+y
npc_refresh(id)
end
function npc_move_up(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,-pixels)
npc_rotate(id,0)
end
function npc_move_down(id,pixels)
if not pixels then pixels=16 end
npc_move(id,0,pixels)
npc_rotate(id,180)
end
function npc_move_left(id,pixels)
if not pixels then pixels=16 end
npc_move(id,-pixels,0)
npc_rotate(id,270)
end
function npc_move_right(id,pixels)
if not pixels then pixels=16 end
npc_move(id,pixels,0)
npc_rotate(id,90)
end
end
you did not set the initArray function, here it's
Code:
1
2
3
4
5
6
7
2
3
4
5
6
7
function initArray(m)
local t = {}
for i = 1,m do
t[i] = 0
end
return t
end
local t = {}
for i = 1,m do
t[i] = 0
end
return t
end



