Forum

> > CS2D > Scripts > Lua Error Spells
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Error Spells

6 replies
To the start Previous 1 Next To the start

old Lua Error Spells

G3tWr3ck3d
User Off Offline

Quote
Hello can someone fix this error?:LUA ERROR: sys/lua/tajifuns_rpg2.0/trpg_engine.lua:335: attempt to perform arithmetic on field '?' (a nil value)
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
addhook("hit","_hit")
function _hit(id,s,wpn,hpdmg,apdmg)
	dmg = math.floor(((hpdmg)/2) + (atk[s] - (def[id]*0.3)))
	barrierdmg = math.ceil(hpdmg + atk[s])
	if dmg <= 0 then
		dmg = 1
	end
	if player(id,"team") ~= player(s,"team") then
		if barrier[id] > 0 then
			barrier[id] = barrier[id] - barrierdmg
			if barrier[id] < 0 then
				barrier[id] = 0
			end
			parse("sv_sound2 "..id.." \"tajifuns_rpg/magicalbarrier.wav\"")
			parse("sv_sound2 "..s.." \"tajifuns_rpg/magicalbarrier.wav\"")
			barrierimg[id] = image("gfx/tajifuns_rpg/barrier.png",player(id,"x"),player(id,"y"),1)
			tween_scale(barrierimg[id],150,0,0)
		else
			if shieldwall[id] == 1 then
				dmg = (math.ceil(dmg*SPELLS[11].power))
			end
			if dmg_ref[id] == 1 then
				dmg = (math.ceil(dmg/SPELLS[9].power))
			end
			if dmg >= hp2[id] then
				-- Kill
				parse('customkill '..s..' "killed" '..id..'')
				add = expratio+math.random(-10,15)
				exp[s] = exp[s] + add
				newexp[s] = newexp[s] + add
				if exp[s] >= needexp[s] then
					lvlup(s)
				end
			else
				hp2[id] = hp2[id] - dmg
			end
		end
		
	end
	return 1
end
line 335:
1
dmg = math.floor(((hpdmg)/2) + (atk[s] - (def[id]*0.3)))
edited 1×, last 08.07.13 11:21:50 am

old Help Code

IRAN TOWN
User Off Offline

Quote
> Write Line 1
1
2
3
4
5
6
7
8
9
Function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
End
return array
End
atk=initArray(32)
def=initArray(32)

• And :
atk[s]=?
def[id]=?

old Re: Lua Error Spells

G3tWr3ck3d
User Off Offline

Quote
Is still saing:
LUA ERROR: sys/lua/tajifuns_rpg2.0/trpg_engine.lua:346: attempt to perform arithmetic on '?' (a nil value)
Line 346:
1
dmg = math.floor(((hpdmg)/2) + (atk[s] - (def[id]*0.3)))
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview