Forum

> > CS2D > Scripts > lua not working
Forums overviewCS2D overview Scripts overviewLog in to reply

English lua not working

10 replies
To the start Previous 1 Next To the start

old lua not working

Masea
Super User Off Offline

Quote
Hi guys, again me with new question.
This code not working:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function around_damagewe(id,x,y,size,dmg)
	for _,eid in pairs(player(0,"tableliving")) do
		parse("explosion "..x.." "..y.." "..size.." "..dmg.." "..id)
		if math.sqrt((player(eid,"x")-x)^2+(player(eid,"y")-y)^2) <= size then
				 heroes_hit(eid, id, 1, dmg)
		end
	end
end

function spunkw(id,x,y,dmg)
		local spunkw = image("gfx/heroes/skills/firecircles_p.png",x,y,0)
		imagecolor(spunkw,0,0,255)
		imagealpha(spunkw,0.7)
		local spunkws = image("gfx/heroes/skills/firecircle_p.png",x,y,0)
		imagealpha(spunkws,0.7)
		tween_scale(spunkws,500,0.1,0.1)
		timer(500,"freeimage",spunkws)
		timer(500,"freeimage",spunkw)
		local ids, xs, ys, dmgs = id, x, y, dmg
		timer(500,"around_damagewe","ids,xs,ys,64,dmgs")
end

ERROR:
1
LUA ERROR: sys/lua/skills.lua:67: attempt to concatenate local 'dmg' (a nil value)

Error line:
1
parse("explosion "..x.." "..y.." "..size.." "..dmg.." "..id)

Thanks.

old Re: lua not working

Rainoth
Moderator Off Offline

Quote
'lua not working' is a very generic title and does not tell us your problem. Change it.

Can you show us where you call the function 'spunkw' ?
Basically what the error is telling you is that it can't concatenate nothing. 'around_damagewe' parameter 'dmg' is nothing (nil) and so it cannot be concatenated in the line where error occurs. So the function isn't getting the value that you send.

Therefore you are:
• Not sending the value correctly
• Not sending the value at all
• Sending the value but it's equal to nil (nothing)

old Re: lua not working

DannyDeth
User Off Offline

Quote
Line 19/20 in your code:
1
2
local ids, xs, ys, dmgs = id, x, y, dmg
	timer(500,"around_damagewe","ids,xs,ys,64,dmgs")
This will pass exactly one argument to the "around_damagewe" function: a string containing "ids,xs,yx,64,dmgs". It will go into the id parametre.

The actual values will not be passed to the function. If you print id, x, y, size and dmg in around_damagewe you will see what I'm talking about.

old Re: lua not working

Masea
Super User Off Offline

Quote
@user J192: Sure;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("menu","heroes_skills")
function heroes_skills(id,t,b)
	if t == 'Skill hotkeys' then
		if b == 2 then
			if char[id] == 1 then
				if mana[id] >= 60 then
					if cd2[id] == 0 then
					  cd2[id] = 12
					  mana[id] = mana[id] - 60
					  spunkw(id,cursorx[id],cursory[id],0.55)
					else
					msg2(id,"You can't use this skill for now.")
					end
				else
				msg2(id,"You don't have enough mana for use this skill.")
				end
			end
		end
	end
end

@user DannyDeth:
I did what you want from me, and you're right. But now, what can I do for fix this?

old Re: lua not working

Rainoth
Moderator Off Offline

Quote
Quote
•Not sending the value correctly

I had suspicions but it was weird for me that dmg was called rather than earlier arguments.

For fixing, maybe you could send a single argument which is a table. For example.
1
2
3
4
5
6
7
MyTable = {}
MyTable.ids = ids
MyTable.xs = xs
MyTable.ys = ys
MyTable.size = 64
MyTable.dmg = dmgs
timer(500,"around_damagewe",MyTable)

Just a blind guess.

old Re: lua not working

Masea
Super User Off Offline

Quote
@user Rainoth: Thanks but not working; in your code screen, at line 7(timer) is not working.

Probably, my wrong at here;
1
2
local ids, xs, ys, dmgs = id, x, y, dmg
timer(500,"around_damagewe","ids,xs,ys,64,dmgs")

I didn't use so many "timer" function in my life, so, probably there is a problem.

Is it true guys?(About code)

old Re: lua not working

Gaios
Reviewer Off Offline

Quote
user Masea has written
I didn't use so many "timer" function in my life, so, probably there is a problem.

timer(500,"parse","lua around_damagewe("..ids..","..xs..","..ys..","..tonumber(64)..","..dmgs..")")

old Re: lua not working

Gaios
Reviewer Off Offline

Quote
@user Masea: timerEx(miliseconds(number),function(string/function),count(number),addtional arguments)
timerEx(500,around_damagewe,1,ids,xs,ys,64,dmgs)


I don't understand why you are using the timer if you installed timerEx.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview