BattleHub Scripting
Moderator: Moderators
BattleHub Scripting
At the moment I am looking for ways of making BattleHub extensible, and Im wondering what languages people are interested in?
Im particularly drawn to JRuby but I don't know how people will feel about that..
Im particularly drawn to JRuby but I don't know how people will feel about that..
Last edited by AF on 08 Jul 2008, 22:24, edited 1 time in total.
Re: Lobby Scripting
python > ruby
if we defined a standard scripting interface, we could easily use the same scripts in multiple lobbies. there is a python unit for delphi, wxscript can interface with python, and my lobby can natively use python
since spring already depends on python, it will at least have the interpreter dll
I would probably also write copious quantities of useful scripts if we had a python scripting interface for lobbies
</fanboi>
if we defined a standard scripting interface, we could easily use the same scripts in multiple lobbies. there is a python unit for delphi, wxscript can interface with python, and my lobby can natively use python
since spring already depends on python, it will at least have the interpreter dll
I would probably also write copious quantities of useful scripts if we had a python scripting interface for lobbies
</fanboi>
Re: Lobby Scripting
Well I have javascript and ruby interfaces already, Ill have a look into jython.
However for the moment I'm not too bothered about lobby standards as the scripts would be instantiating java objects and communicating with java objects, and a lot of the APIs and features available wont make sense in other lobbies.
For example inserting buttons smilies and images into chat text only makes sense in my lobby which is the only lobby so far to support it.
That said if it were put forward I wouldn't mind adding support for any additional standardized scripting interfaces that are discussed here.
hmmm the jython website only provides an installer, and Im not so sure how Id go about embedding it in battlehub.
However for the moment I'm not too bothered about lobby standards as the scripts would be instantiating java objects and communicating with java objects, and a lot of the APIs and features available wont make sense in other lobbies.
For example inserting buttons smilies and images into chat text only makes sense in my lobby which is the only lobby so far to support it.
That said if it were put forward I wouldn't mind adding support for any additional standardized scripting interfaces that are discussed here.
hmmm the jython website only provides an installer, and Im not so sure how Id go about embedding it in battlehub.
Re: Lobby Scripting
abstraction is good in a scripting interface; playing with java in your interpreted language is ugly
the interface would need to provide:
the interface would need to provide:
- a way to register a handler for protocol events (i.e. SAID, OPENEDBATTLE, SAY, etc), both incoming and outgoing
- functions to handle common lobby actions and to access information (current channels, users, battles, lobby capabilities, etc)
- functions to handle specific lobby actions - scripts can disable certain functionality or refuse to run entirely if the lobby doesn't support it (like your smiley example)
Re: Lobby Scripting
check Demo/embed/ after installing jython
Re: Lobby Scripting
Lua! Lots of coders involved with Spring know how to use it.
Re: Lobby Scripting
C! Lots of coders involved with Spring know how to use it.
interface specification draft:
protocol handling:
interface specification draft:
protocol handling:
- handleIncoming( event, handler )
- handleOutgoing( event, handler )
- modify server list
- rename account
- change password
- hash password
- join/leave/host battle
- send messages
- format text
- make smilies
- more stuff
Re: Lobby Scripting
luajava requires the usage of a native binary which could greatly complicate the deployment of battlehub, whereas JRuby and Jython are pure java.
But as I said, abstraction would take my 3 day ETA and turn it into a 30 day ETA, and I have other features to be getting on with.
But as I said, abstraction would take my 3 day ETA and turn it into a 30 day ETA, and I have other features to be getting on with.
Re: Lobby Scripting
Just define a good abstract interface for start
Re: Lobby Scripting
java 6 has a javascript interpreter in the standard distribution, right? might as well use that.
Re: Lobby Scripting
Ive got jython working anyway
Re: Lobby Scripting
SLI and SLO make no sense in the context of the warzone2100 ta3d OTA and glest communities.
Any scripting would also make hefty use of OO
Any scripting would also make hefty use of OO
Re: Lobby Scripting
I will provide python code for handling each raw protocol event from the server
a lobby will simply need two function calls hooking into the handler
one will be when the lobby receives a protocol event, before it handles it itself
it will pass the entire line from the server to the python function and receive it back, modified or unmodified
it will parse the line it receives from the python handler instead of the line it received from the server, and not parse at all if it receives a blank string
psuedo code example
the same applies to sending data
before sending data to a socket, you send it to the python handler
and send the string the python handler returned instead of what you would have sent
psuedo code example
another interface the python scripting will need abstracted is a simple way to add configuration options in the lobby
so you can call a function to enable a configuration tab for the script, then add checkboxes, input fields, etc
then give api functions to get these custom config options
a lobby will simply need two function calls hooking into the handler
one will be when the lobby receives a protocol event, before it handles it itself
it will pass the entire line from the server to the python function and receive it back, modified or unmodified
it will parse the line it receives from the python handler instead of the line it received from the server, and not parse at all if it receives a blank string
psuedo code example
Code: Select all
data = recieveDataFromServer()
data = pythonParseDataFromServer(data)
locallyHandleData(data)
before sending data to a socket, you send it to the python handler
and send the string the python handler returned instead of what you would have sent
psuedo code example
Code: Select all
dataToSend = pythonParseDataFromServer(dataToSend)
sendData(data)
so you can call a function to enable a configuration tab for the script, then add checkboxes, input fields, etc
then give api functions to get these custom config options
Re: Lobby Scripting
Scripting is currently working at a basic level.
API draft:
Functions the lobby must call in the handler:
API draft:
Code: Select all
import lobbyscript
api = lobbyscript.Callback()
api.function()
- handleIn( string data )
Handles each line of incoming protocol. the lobby processes whatever data the function returns instead of the data received from the server - handleOut( string data )
Handles each line of outgoing protocol, the lobby sends whatever this function returns instead of the original string - onDisconnect()
Lobby calls before closing the socket to disconnect from the server - onClose()
Lobby calls before exiting, after the socket has been closed
- Meta commands:
- LoadScripts()
Invoke's the handler's _load() function (no arguments) which loads any new modules which have not been loaded - ReloadScripts()
Invokes the handler's _reloadall() function (no arguments) which reloads all loaded scripts - ReloadScript( string scriptName )
Invokes the handler's _reload( string scriptName ) function which reloads the specified script
- Protocol commands:
- SendProtocol( string data )
Send a single line of protocol to the server; newline will be appended before sending - HandleProtocol( string data )
Handle a single line as if it were received from the server, no newline required
- Lobby control commands:
- Disconnect()
Closes the socket - ExitLobby()
Closes the lobby
- Unitsync control commands:
- User data commands:
Last edited by aegis on 09 Jul 2008, 02:40, edited 1 time in total.