Forum

> > CS2D > Scripts > Lua Error! : Unprotected error in call to Lua AP
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Error! : Unprotected error in call to Lua AP

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: Lua Error! : Unprotected error in call to Lua AP

Rainoth
Moderator Off Offline

Zitieren
I can't really guarantee but I THINK that I had the same problem some time ago. You could try searching for it.

// Alright, a little searching resulted in me finding a certain post. This can be caused when you call a table that doesn't even exist.

alt Re: Lua Error! : Unprotected error in call to Lua AP

Starkkz
Moderator Off Offline

Zitieren
1
unprotected error in call to Lua API
Are you sure that you're not running any library or something? As far as I know CS2D calls the Lua code with lua_pcall (protected call). The only way this could happen is a Lua (written in C code) module being using lua_call, and it being causing an error (which in this case would be iterating a table with a nil key).

alt Re: Lua Error! : Unprotected error in call to Lua AP

_Yank
User Off Offline

Zitieren
@user Rainoth: So actually I was right, I now regret from editing the post. Anyway, @user Ajmin, it seems that the script is trying to execute a function which haven't been set. Your best solution should be to check if you're running all the scripts you were running when the server were working properly. If so, try to find if there's non-existent lua function calls on the code.
A good case, for example, for the string.split function, it does not exist by default you must create it. Or for the table.contain function, it does not exist by default.

alt Re: Lua Error! : Unprotected error in call to Lua AP

Rainoth
Moderator Off Offline

Zitieren
Also see if you're not calling something like
1
timer(1000,"parse","lua variable[id]=1")
or at least something similar. I remember getting that error when I wrote that somehow improperly. DC told me that the way I did it, it was
Starkkz hat geschrieben
Lua (written in C code) module being using lua_call

alt Re: Lua Error! : Unprotected error in call to Lua AP

Starkkz
Moderator Off Offline

Zitieren
@user Rainoth: Timer does that? If so, it must be calling directly a lua function, and inside that Lua function there's a variable that is being assigned to a value and it's key is nil. I don't think it's through parse, the "lua" command must have a protected call to the Lua API too.

1
2
3
4
function func()
	variable[id] = 1
end
timer(1000, "func", "")
I belive it looks like that, where the key "id" is nil and the timer is calling "func" from the global variables.

alt Re: Lua Error! : Unprotected error in call to Lua AP

MikuAuahDark
User Off Offline

Zitieren
Calling a cs2d lua cmd timer like this for example:
1
2
3
temp={}
temp[1]={}
timer(100,"temp.test.asd")
causes that error.
The structure of the index example:
1
2
3
4
5
6
7
8
temp={
	test={
		-- if this nil, it does protected
		asd={
			-- if this nil, it doesn't protected anymore
		}
	}
}

I tested user Starkkz and user Rainoth code and the call does protected. It does happend if you try to use my code above.

EDIT: I try this code
1
2
3
-- same table above.
temp={}
local a,b=pcall(timer,1000,"temp.test.asd")
And it doesn't help anyway. Maybe you can replace timer function(before all lua is executed) with something like this
1
2
3
4
5
6
7
__unsafeTimer=timer
function timer(a,b,c,d)
	local e,f=pcall(loadstring("return "..b))
	if e==false then error(f) end
	if type(f)~="function" then error(b.." is not a function") end
	return __unsafeTimer(a,b,c,d)
end
2× editiert, zuletzt 15.12.14 05:54:33
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht