Forum

> > CS2D > Scripts > LuaJIT, is it possible ?
Forums overviewCS2D overview Scripts overviewLog in to reply

English LuaJIT, is it possible ?

7 replies
To the start Previous 1 Next To the start

old LuaJIT, is it possible ?

_Yank
User Off Offline

Quote
Greetings.
Well, as the thread title shows, i'm here to ask if it is possible to load LuaJIT with cs2d.

LuaJIT is a faster version version of lua. I don't know if it will really do a big difference in cs2d, just curious.

Well I've read that i can load libraries in cs2d but since i don't know how they work i didn't understood at all. I only know how to load a library ( dll ) in cs2d with require command. ( Of course, only if it is windows )

Just don't know how to load it in Linux systems like Ubuntu.

So, would like if there is someone that can explain me how they work and how to load them in linux systems since i want to load LuaJIT on cs2d on a Linux Machine.

http://luajit.org/index.html
Thanks.

old Re: LuaJIT, is it possible ?

_Yank
User Off Offline

Quote
Wow, huge speed difference. Well anyways, thanks a lot
Well still like to know how i can load a library in Linux (That thing which comes with something called MAKEFILE)

But, 1 question, it's still possible in windows ? I mean, long time ago a friend sent me the dll of luajit for windows x32 and in Starkkz admin script i remember that i saw that it loads the lua51 dll.

Anyways thanks.

old Re: LuaJIT, is it possible ?

DC
Admin Off Offline

Quote
Yes I would have to change CS2D to make this work directly. The point is that the big majority of CS2D scripts are quite short / inexpensive and therefore they don't really need JIT. For this reason I didn't take a closer look at this yet and I also didn't consider to replace the current implementation with a JIT version yet (as this might lead to new bugs/problems).

old Re: LuaJIT, is it possible ?

FlooD
GAME BANNED Off Offline

Quote
no point for cs2d.
0.0001s vs 0.00001s really isn't worth the effort

if any cs2d script is causing significant performance issues (i.e. takes more than 10ms per frame), it would be because the script is poorly coded

i think the heaviest script in cs2d is probably DC's AI and even with that you can have a server with 30 bots without any noticeable performance problems (on modern hardware of course)

old Re: LuaJIT, is it possible ?

VaiN
User Off Offline

Quote
I would like to at least have the option of using LuaJIT though I understand it's probably not worth the hassle.

For my scripts I tend to go well above and beyond what other people create especially with the achievement system I'm working on now. So far it's at about 3.3mb in size with more features planned.

I certainly do my best to make things efficient, but it's gonna slow down at some point. So far so good though.

old Re: LuaJIT, is it possible ?

mafia_man
User Off Offline

Quote
Forgot to mention that with LuaJIT you can easily extern C functions. Example:
1
2
3
4
5
local ffi = require("ffi")
ffi.cdef[[
int MessageBoxA(void *w, const char *txt, const char *cap, int type);
]]
ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
You can easily detect user OS:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local ffi = require("ffi")
ffi.cdef[[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]

local sleep
if ffi.os == "Windows" then
  function sleep(s)
    ffi.C.Sleep(s*1000)
  end
else
  function sleep(s)
    ffi.C.poll(nil, 0, s*1000)
  end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview