Forum

> > CS2D > Scripts > Split lua & LUA Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Split lua & LUA Error

3 replies
To the start Previous 1 Next To the start

old Split lua & LUA Error

ReVoltage
User Off Offline

Quote
hello guys us
i have a few question about lua
1.Is there any different if i split the lua into a many file?
example: i have war.lua
and i split it into admin.lua , menu.lua ,say.lua , command .lua
is there any effect? is it reduce lag caused by lua?

2.I have a LUA Error in my script, the error is:
1
LUA ERROR: C stack overflow
idk where my fault this is the code
Spoiler >

its happen when i hit a zombie (NPC) so i think there is the problem
thx before
sorry for my bad english

old Re: Split lua & LUA Error

gotya2
GAME BANNED Off Offline

Quote
Probably there is stack overflow because in the hook "objectdamage" you parse "damageobject" ( who the hell named it this confusing way?! ), which in turn calls the hook "objectdamage" again and turns it into an infinite loop.

similary, this will give a stack overflow:

1
2
3
function a(c)
   return a(c-1)
end

You can fix this by limiting the number of times "damageobject" is parsed, by putting a if statement around it.

Splitting your code into multiple lua files is good practice, one could reuse lua files for another project if the same functionality is required.

old Re: Split lua & LUA Error

ReVoltage
User Off Offline

Quote
user gotya2 has written
Probably there is stack overflow because in the hook "objectdamage" you parse "damageobject" ( who the hell named it this confusing way?! ), which in turn calls the hook "objectdamage" again and turns it into an infinite loop.

similary, this will give a stack overflow:

1
2
3
function a(c)
   return a(c-1)
end

You can fix this by limiting the number of times "damageobject" is parsed, by putting a if statement around it.

thank you
but i dont understand i will try to understand
i will try by changing my code
EDIT: so there is no effect if i split my lua? no reduce lag?

old Re: Split lua & LUA Error

HeX
User Off Offline

Quote
server.lua

dofile("sys/lua/Folder with other lua's idk/admin.lua/munu.lua/say.lua/commands.lua)


if i correctly understood your question.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview