Forum

> > News > CS2D Beta 0.1.2.6
Forums overviewNews overviewLog in to reply

English CS2D Beta 0.1.2.6

90 replies
Page
To the start Previous 1 2 3 4 5 Next To the start

old Re: CS2D Beta 0.1.2.6

1uP
User Off Offline

Quote
dont like it at all, hate when the rifles are not that loud as before

old Re: CS2D Beta 0.1.2.6

_Yank
User Off Offline

Quote
About the luajit thingy, I think you should not remove it but, make it unsupported. We would then have 2 dedicated versions, the standart Lua one and LuaJIT one, discouraged to use and with fewer support.

old Re: CS2D Beta 0.1.2.6

Starkkz
Moderator Off Offline

Quote
@user DC: Hey,

I just found out a method to get a better tracing for Lua errors, it might be useful for CS2D. Maybe you could apply it to the hotfix, so it becomes easier to fix broken scripts. I just built this code and tested it. It's necessary to replace PRINT_ERROR_TO_CS2D_CONSOLE with the actual function that prints those errors.
And if you're using:
luaL_dofile, luaL_loadfile or any other load function with luaL_dofile2
lua_pcall with lua_pcall2
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
Function PRINT_ERROR_TO_CS2D_CONSOLE(ERROR:String)
	Print "Lua Error: " +  Error
EndFunction

Function lua_traceback:Int(L:Byte Ptr)
	If Not lua_isstring(L, 1) Then
		Return 1
	EndIf
	lua_getfield(L, LUA_GLOBALSINDEX, "debug")
	If Not lua_istable(L, -1) Then
		lua_pop(L, 1)
		PRINT_ERROR_TO_CS2D_CONSOLE(lua_tostring(L, -1))
		Return 1
	EndIf
	lua_getfield(L, -1, "traceback")
	If Not lua_isfunction(L, -1) Then
		lua_pop(L, 2)
		PRINT_ERROR_TO_CS2D_CONSOLE(lua_tostring(L, -1))
		Return 1
	EndIf
	lua_pushvalue(L, 1)
	lua_pushinteger(L, 2)
	lua_call(L, 2, 1)
	PRINT_ERROR_TO_CS2D_CONSOLE(lua_tostring(L, -1))
	Return 1
EndFunction

Function luaL_dofile2:Int(L:Byte Ptr, Path:String)
	lua_pushcfunction(L, lua_traceback)
	If luaL_loadfile(L, Path) Then
		PRINT_ERROR_TO_CS2D_CONSOLE(lua_tostring(L, -1))
	Else
		lua_pcall(L, 0, 0, lua_gettop(L) - 1)
	EndIf
EndFunction

' Notice that I removed the errfunc:Int argument here
Function lua_pcall2:Int(L:Byte Ptr, nargs:Int, nresults:Int)
	lua_pushcfunction(L, lua_traceback)
	If lua_pcall(L, nargs, nresults, 1) Then
		PRINT_ERROR_TO_CS2D_CONSOLE(lua_tostring(L, -1))
	Else
		lua_pcall(L, 0, 0, lua_gettop(L) - 1)
	EndIf
EndFunction

So I tried this test code.
1
2
3
4
5
6
7
8
9
10
11
function a()
	error("testing")
end

function b()
	a()
end

function c()
	b()
end

And it prints the error + traceback.
1
2
3
4
5
6
Lua Error: test.lua:2: testing
stack traceback:
	[C]: in function 'error'
	test.lua:2: in function 'a'
	test.lua:6: in function 'b'
	test.lua:10: in function <test.lua:9>

It works with the Lua function debug.traceback, so if someone ever removes that function in the Lua code. I made sure that it would at least print the first line from the error.

Edit: If you could apply that asap to all versions of CS2D and cs2d_dedicated it would also be very helpful because there are still remains of LuaJIT-2.0.0 beta-4, and most stack overflow errors were fixed from LuaJIT-2.0.0 beta-6 to LuaJIT-2.0.4. At least windows cs2d_dedicated is still beta 4.
edited 1×, last 23.06.15 05:46:32 pm

old Re: CS2D Beta 0.1.2.6

DC
Admin Off Offline

Quote
@user Starkkz: What is the second pcall in line 43 good for? Also I need pcall to return 0 in case of no error and anything else in case of an error because in some cases I need my own additional error handling.

Also this means a shitload of replacement work for me with a super crappy IDE

old Re: CS2D Beta 0.1.2.6

Starkkz
Moderator Off Offline

Quote
@user DC: The second pcall pushes any result into the traceback and calls it. But I'll try to adapt the code a bit more so you will be able to retreive a value for the additional error handling. I haven't tested what the second pcall returns, it could probably be what traceback returns.

old Re: CS2D Beta 0.1.2.6

Starkkz
Moderator Off Offline

Quote
@user francis007: I'm not pro, I just.
1. Copy
2. Test
3. Approve
Those functions I gave were broken, I had to make two new ones.
But if there's a god existing somewhere there, I hope he blesses us with stability over LuaJIT 2.0.3, and no random stack overflow(s).

old Re: CS2D Beta 0.1.2.6

_Yank
User Off Offline

Quote
It seems that most of you don't know the possibilities LuaJIT could bring... Sadly.

old Re: CS2D Beta 0.1.2.6

VaiN
User Off Offline

Quote
Since a lot of people were complaining and requesting a rollback to Lua from LuaJIT I feel obligated to chime in.

First of all, @user DC: THANK YOU! LuaJIT (+FFI) would really open up a lot of potential and further advance the life of this game. I truly appreciate your efforts with this update. Same to you @user Starkkz: for helping him out.

And second, to those with issues, no one told you that you had to update. Just because it's new doesn't mean you have to use it. Feel free to use the previous version until the new one suits you. Be patient and provide helpful feedback.

old Re: CS2D Beta 0.1.2.6

DC
Admin Off Offline

Quote
I guess you're in the wrong thread? There was no rollback from LuaJIT to Lua in 0.1.2.6
To the start Previous 1 2 3 4 5 Next To the start
Log in to replyNews overviewForums overview