Forum

> > CS2D > Scripts > Split lua & LUA Error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Split lua & LUA Error

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Split lua & LUA Error

ReVoltage
User Off Offline

Zitieren
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

alt Re: Split lua & LUA Error

gotya2
GAME BANNED Off Offline

Zitieren
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.

alt Re: Split lua & LUA Error

ReVoltage
User Off Offline

Zitieren
user gotya2 hat geschrieben
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?

alt Re: Split lua & LUA Error

HeX
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht