Forum

> > CS2D > Scripts > New Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English New Error

13 replies
To the start Previous 1 Next To the start

old New Error

kalis
User Off Offline

Quote
hey all
i'm going make new lua
and get new error :
1
LUA ERROR: C stack overflow

how to fix ?

hey help me
edited 1×, last 11.05.11 01:54:35 pm

old Re: New Error

DannyDeth
User Off Offline

Quote
Well, here goes the stack info!

Look, when Lua is included in a program, it has a 'stack' where arguments for the functions in C are stored. If this thing isn't big enough to hold everything, it throws this error. Usually you could use the command:
1
lua_checkstack(lua_state,extra_space)
However, because you don't have access to CS2D's source code, you cannot do this. So, yeah, I can't really help here much.

EDIT: Dude, we aren't allowed to push threads.

EDIT2: Fixed some info.

old Re: New Error

kalis
User Off Offline

Quote
here is code
help me fix it

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
----Zombie Lua---

--lua by kalis --


function Array(size,value)
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end



zombie = Array(32,0)
image_z = Array(32,0)
z_score = Array(32,0)



addhook("team","team")
function team(id,t)
	if t == 0 and player(id,"exists") then
		parse("makect "..id)
	end
	if t == 0 and player(id,"exists") then
		z_score[id] = 0
	end
	if t == 1 then
		zombie[id] = 1
	end
	if zombie[id] == 1 then
		parse("maket "..id)
		return 1
	end
end

addhook("startround","start")
function start()
	for id = 1,32 do
		z_score[id] = 0
	end
	if player(0,'table') then
		one_vam = 0
	end
	local vampire = player(0,'table')
	for i = 1, #player(0,"table") do
		if player(vampire[i],'exists') and one_vam == 0 then
			one_vam = 1
			parse('maket '..vampire[i])
		end
	end
end



addhook("move","z_spawn")
function z_spawn(id)
if player(0,"table") then
	if zombie[id]==1 then
		if z_score[id] == 1 then
			freeimage(image_z[id])
			image_z[id] = image("gfx/zombie.bmp",player(id,"x"),player(id,"y"),132+id)
			imagealpha(image_z[id],1)
		end
		if z_score[id]==2 then
			freeimage(image_z[id])
			image_z[id] = image("gfx/zombie.bmp",player(id,"x"),player(id,"y"),132+id)
			imagealpha(image_z[id],0.5)
		end
	end
end
end

addhook("kill","z_kill")
function z_kill(killer,victim,wpn)
	if zombie[killer] == 1 then
		z_score[killer] = z_score[killer] + 1
		msg2(victim,"©212212212You get died by "..player(killer,"name"))
		parse("maket "..victim)
		return 1
	end
end

addhook("say","z_say")
function z_say(id,txt)
if txt=="star" then
	msg2(id,"your score : "..z_score[id].." .")
end
end

old Re: New Error

DannyDeth
User Off Offline

Quote
It isn't your script. It's most probably the sheer amount of scripts you are running. Make sure you only run this script, otherwise check that you aren't using to many things like reqcld() and player() functions as these extract information from the actual program and therefore use the stack.

old Re: New Error

kalis
User Off Offline

Quote
why not my script =.=
and i must delete some function in ? player() ?

old Re: New Error

DannyDeth
User Off Offline

Quote
Read me first post completely, otherwise you won't understand it at all. Now look here, change this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("move","z_spawn")
function z_spawn(id)
if player(0,"table") then
     if zombie[id]==1 then
          if z_score[id] == 1 then
               freeimage(image_z[id])
               image_z[id] = image("gfx/zombie.bmp",player(id,"x"),player(id,"y"),132+id)
               imagealpha(image_z[id],1)
          end
          if z_score[id]==2 then
               freeimage(image_z[id])
               image_z[id] = image("gfx/zombie.bmp",player(id,"x"),player(id,"y"),132+id)
               imagealpha(image_z[id],0.5)
          end
     end
end
end

into:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ddhook("move","z_spawn")
function z_spawn(id)
if player(0,"table") then
	if zombie[id]==1 then
          local da_zombie_x = player(id,"x")
          local da_zombie_y = player(id,"y")
		if z_score[id] == 1 then
			freeimage(image_z[id])
			image_z[id] = image("gfx/zombie.bmp",da_zombie_x,_da_zombie_y,132+id)
			imagealpha(image_z[id],1)
		elseif z_score[id] == 2 then
			freeimage(image_z[id])
			image_z[id] = image("gfx/zombie.bmp",da_zombie_x,_da_zombie_y,132+id)
			imagealpha(image_z[id],0.5)
		end
	end
end
end
See how it only uses player() twice instead of four times? What happens is that Lua says "Hey, CS2D server, order up the X-position of the player with this ID and leave it on the stack for me!". So, the cs2d server leaves the X on the stack to be collected by Lua and given to the variable.

old Re: New Error

kalis
User Off Offline

Quote
hey ERROR still have
error not in function z_spawn
it error in other fuction

it error in addhook "team
i see error
1
2
3
4
if t == 1 then
		parse("maket "..id)
		return 1
	end

i cant fix!
edited 1×, last 12.05.11 06:26:28 am

old Re: New Error

DannyDeth
User Off Offline

Quote
Well, just tell me the actual error and I might be able to help you.

old Re: New Error

kalis
User Off Offline

Quote
now i fix it
i cant fix but
i delete it
change the orther code
and it not error more!
thank danny Deth =.=

old Re: New Error

Dovahkin
User Off Offline

Quote
Omg what a noob heocon!

if t == 1 --terrorist -.-
     parse("maket -- ?

omg omg omg,

1
2
3
4
5
6
7
8
9
10
11
12
addhook("team","teamcheck")
function teamcheck(id)
	if player(id,"team")==2 then
		parse("maket "..id)
	end
	if player(id,"team")==0 then
		parse("maket "..id)
	end
	if player(id,"team")==1 then
		parse("makect "..id)
	end
end


lololo

old Re: New Error

kalis
User Off Offline

Quote
=.=
i say it is error

full code not this

Function team(t,id)
==.=!

old Re: New Error

DannyDeth
User Off Offline

Quote
user Dovahkin has written
Omg what a noob heocon!
...
omg omg omg
...
lololo

Is that really necessary? No, it isn't, no need for insults, I mean, considering you were much worse than him less than 2 months ago and the fact that you have removed a vital piece of his code means there is absolutely no need for the flame, man. Keep the peace for the good of God.

Heocon, here is some code that will do what you want it to do:
More >


Just say if you get any errors, I haven't tested it.
Enjoy

old Re: New Error

kalis
User Off Offline

Quote
it have some error
but very very thanks you
but i can get some idea from your code danny!

old Re: New Error

DannyDeth
User Off Offline

Quote
Thanks, I'm fixing up the errors now. I'll post the code in a minute.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview