jsbzflag - scripting bzfs with Javascript.

Expand and mod your server.
Post Reply
User avatar
mmarshall
Private First Class
Private First Class
Posts: 9
Joined: Sat Apr 30, 2005 2:43 am
Location: Dallas/Fort Worth area
Contact:

jsbzflag - scripting bzfs with Javascript.

Post by mmarshall »

I wanted to do something different over the weekend, and Google's new javascript engine was just begging to be played with.

Get it here: http://bitbucket.org/mmarshall/jsbzflag/

What does it look like? Here's a simple "airspawn" plugin in its entirety:

Code: Select all

events.getPlayerSpawnPos.add(function () {
    this.pos[2] += Math.random()*10;
});
It's not complete, but what's there works pretty well. Some documentation and a few samples are included.

Anyway, my weekend is over. Have fun with it!

MWM
Last edited by mmarshall on Sun Aug 09, 2009 3:25 am, edited 1 time in total.
Anthony
Private First Class
Private First Class
Posts: 222
Joined: Fri Jan 11, 2008 4:01 pm

Post by Anthony »

Will this work ?
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

tonywolfe121 wrote:Will this work ?
Will what work?
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
mmarshall
Private First Class
Private First Class
Posts: 9
Joined: Sat Apr 30, 2005 2:43 am
Location: Dallas/Fort Worth area
Contact:

Post by mmarshall »

tonywolfe121 wrote:Will this work ?
If "this" refers to the plugin, it already works. It has been working since day 1 (last Saturday.)

It's just doesn't have the full functionality of the C++ api exposed yet.

MWM
javawizard2539
Private First Class
Private First Class
Posts: 22
Joined: Wed Nov 07, 2007 9:20 pm
Location: Same place as TR

Windows anyone?

Post by javawizard2539 »

Has anyone compiled this on Windows? It gives me a ton of errors when I run scons (compiling v8 worked fine).

Code: Select all

C:\bzflagdev\javascriptplugin\repository>scons
scons: Reading SConscript files ...
C:\Program Files\Python26\Scripts\..\Lib\site-packages\scons-1.1.0\SCons\Platfor
m\posix.py:38: DeprecationWarning: The popen2 module is deprecated.  Use the sub
process module.
  import popen2
C:\Program Files\Python26\Scripts\..\Lib\site-packages\scons-1.1.0\SCons\Tool\ms
vs.py:37: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
scons: done reading SConscript files.
scons: Building targets ...
cl /Fobz_functions.obj /c bz_functions.cpp /nologo - g /TP /nologo - g /I.
cl : Command line warning D9002 : ignoring unknown option '-'
cl : Command line warning D9002 : ignoring unknown option '-'
bz_functions.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
g
c1xx : fatal error C1083: Cannot open source file: 'g': No such file or director
y
g
c1xx : fatal error C1083: Cannot open source file: 'g': No such file or director
y
Generating Code...
scons: *** [bz_functions.obj] Error 2
scons: building terminated because of errors.

C:\bzflagdev\javascriptplugin\repository>
Alexander Boyd
User avatar
mmarshall
Private First Class
Private First Class
Posts: 9
Joined: Sat Apr 30, 2005 2:43 am
Location: Dallas/Fort Worth area
Contact:

Post by mmarshall »

Hmm, you might try commenting out line 11 of the SConstruct file. (I'm not even sure why that's there, come to think of it.)

MWM
javawizard2539
Private First Class
Private First Class
Posts: 22
Joined: Wed Nov 07, 2007 9:20 pm
Location: Same place as TR

Post by javawizard2539 »

Now I'm getting different errors, that look like they are syntax errors within the files. I changed the cpppath and libpath to point to where I have bzfsAPI.h, v8.h, and v8.lib, but it didn't help. I also changed jsbzflag.so to jsbzflag.dll.

Here's a portion (roughly one-third) of the errors that are occuring, which look to me like they're occuring because the header files can't be found. I don't know a ton about Scons, but I haven't been able to solve the problem from the research I've done on it.

Code: Select all

C:\bzflagdev\javascriptplugin\repository>scons
scons: Reading SConscript files ...
C:\Program Files\Python26\Scripts\..\Lib\site-packages\scons-1.1.0\SCons\Platfor
m\posix.py:38: DeprecationWarning: The popen2 module is deprecated.  Use the sub
process module.
  import popen2
C:\Program Files\Python26\Scripts\..\Lib\site-packages\scons-1.1.0\SCons\Tool\ms
vs.py:37: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
scons: done reading SConscript files.
scons: Building targets ...
cl /Fojsbzflag.obj /c jsbzflag.cpp /nologo /TP /nologo /I.
jsbzflag.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
jsbzflag.cpp(230) : error C2065: 'bz_GetPlayerSpawnPosEventData' : undeclared id
entifier
jsbzflag.cpp(230) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(230) : error C2065: 'bz_GetPlayerSpawnPosEventData' : undeclared id
entifier
jsbzflag.cpp(230) : error C2059: syntax error : ')'
jsbzflag.cpp(231) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(231) : error C2227: left of '->pos' must point to class/struct/unio
n/generic type
        type is ''unknown-type''
jsbzflag.cpp(232) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(232) : error C2227: left of '->handled' must point to class/struct/
union/generic type
        type is ''unknown-type''
jsbzflag.cpp(233) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(233) : error C2227: left of '->rot' must point to class/struct/unio
n/generic type
        type is ''unknown-type''
jsbzflag.cpp(234) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(234) : error C2227: left of '->time' must point to class/struct/uni
on/generic type
        type is ''unknown-type''
jsbzflag.cpp(235) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(235) : error C2227: left of '->playerID' must point to class/struct
/union/generic type
        type is ''unknown-type''
jsbzflag.cpp(240) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(240) : error C2227: left of '->pos' must point to class/struct/unio
n/generic type
        type is ''unknown-type''
jsbzflag.cpp(241) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(241) : error C2227: left of '->handled' must point to class/struct/
union/generic type
        type is ''unknown-type''
jsbzflag.cpp(242) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(242) : error C2227: left of '->rot' must point to class/struct/unio
n/generic type
        type is ''unknown-type''
jsbzflag.cpp(248) : error C2065: 'bz_UnknownSlashCommandEventData' : undeclared
identifier
jsbzflag.cpp(248) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(248) : error C2065: 'bz_UnknownSlashCommandEventData' : undeclared
identifier
jsbzflag.cpp(248) : error C2059: syntax error : ')'
jsbzflag.cpp(249) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(249) : error C2227: left of '->message' must point to class/struct/
union/generic type
        type is ''unknown-type''
jsbzflag.cpp(249) : error C2228: left of '.c_str' must have class/struct/union
jsbzflag.cpp(250) : error C2065: 'event' : undeclared identifier
jsbzflag.cpp(250) : error C2227: left of '->from' must point to class/struct/uni
on/generic type
        type is ''unknown-type''
Alexander Boyd
User avatar
mmarshall
Private First Class
Private First Class
Posts: 9
Joined: Sat Apr 30, 2005 2:43 am
Location: Dallas/Fort Worth area
Contact:

Post by mmarshall »

It looks like bzfsAPI.h isn't being included, or perhaps is a different version. (I developed against 2.0.12.)

You can also try compiling with a VC project instead of scons. It's just jsbzflag.cpp, player.cpp and bz_functions.cpp linked with v8.

MWM
javawizard2539
Private First Class
Private First Class
Posts: 22
Joined: Wed Nov 07, 2007 9:20 pm
Location: Same place as TR

Post by javawizard2539 »

That would be the problem. I'm building against BZFlag version 3.0, and if I remember correctly a lot has changed in the API. I'll try building for 2.0.
Alexander Boyd
Post Reply