CM EDITION for Sauerbraten Collect
-----------------------------------------
Copyright (c) 2013 cm|ac
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
----------------------------------------------------------------------------------
cm|ac, avg 2013, v0.5 beta
features lua scripting (LuaJit2.0.0 scripting with ffi library support - win only for now)
sauer mods made easy with lua (easy scripting language, no compile needed)
build maps with lua, read geometry info, filter received edits, detect/respond to sauer
game events like edittoggle, shots, damage...
send/receive any file, unspec yourself locally on any server
lua example files with custom mods: (main file that gets auto executed is config.lua)
------------------------------------
multiplayer games: 1st person minesweeper, sokoban with .sok level loader,
client multiplayer game modes: hide and seek (zombies), last man standing ,fall damage ...
typewrite system for sauer ( write in coopedit with custom character sets made out of cubes )
client auth system via chat, player movement recorder/playback
INSTALATION: (windows)
---------------------
unpack win binary.ZIP to your main sauerbraten directory (no files will be overwritten, just added)
run sauerbratencmed.bat (or run sauebraten.bat but change inside sauerbraten.exe to cmsauerbraten.exe)
Lua files must be saved in same directory as cmsauerbraten.bat
64 BIT WINDOWS USERS:
run cmsauerbraten.bat, it will run 32 bit binary which works fine
SOURCE COMPILATION:
------------------
compile on windows:
1. need msys with mingw compiler installed
2. run msys, cd to makefile directory and "make"
3. binary is created inside /bin/, its cmsauerbraten.exe
--------------------------
compile on linux:
make sure executable bits are set on for file /enet/configure before compiling.
note: lua_export_FFI doesnt work on linux, so all lines
starting with lua_export_FFI inside cmed_lua.cpp need to be // commented for compile to work
luajit ffi related note:
problem: how to export symbols so they can be used with ffi?
1. open console, cd to directory containing makefile
2. make
3. copy created sauer_client binary to your sauerbraten binary directory
Thanks to netman87 for help with makefiles.
/ / / / / / / / - - - - - - - - - - - - - - - - - - / / / / / / / /
C M E D I T I O N C O M M A N D G U I D E R E F E R E N C E :
/ / / / / / / / - - - - - - - - - - - - - - - - - - / / / / / / / /
new CUBESCRIPT functions: ( to use inside game by typing into chat ):
---------------------
reset_lua resets lua system ( deletes all variables, function definitions ... and restarts )
execl executes lua file
SYNTAX: /execl $string
lua runs string as lua command, makes any lua command available to cubeScript
SYNTAX: /lua $string
senddata sends arbitrary file to normal sauerbraten servers
SYNTAX: /senddata $filename
file must be in your main sauerbraten install/home directory (or subdirectory)
getdata receive file from normal sauerbraten server and save it as a data file
SYNTAX: /getdata $filename
file is saved in your sauerbraten home directory (as set in run script for sauer)
gettexinfo get vcommand info for specified texture number
unspec unspectates player (locally) on locked mastermode to walk around
MYPING changes ping
CMSPREAD control weapon spread
CMEVENT 1: event monitoring on
CMRENDER 1: circuit rendering on
---
SERVER:
new CUBESCRIPT functions:
--------------------------------------------------
cmservmsg cn text
send server msg to cn
cmdamage tcn acn damage gun
does damage ( or heal) on player, note its affected by lua_damage function
cmsetammo cn gun1 gun2 gun3 gun4 gun5 gun6
sets ammo and sends player to spawn ( no kill )
cmspeed cn speed
sets gamespeed for player only ( if cn == -1 then global)
cmshotfx cn gun x1 y1 z1 x2 y2 z2
cmsetclientinfo cn mode val
cmgetclientinfo cn mode ; mode 1 privilege,2 name, 3 team, 4 state
server events:
lua_N_EVENT: teleport, jumppad, editmode, tryspawn, spawn, gunselect, shoot, item pickup
lua_N_TEXT: chat, server chat command with #
LUA functions: (functions available in lua scripts)
--------------------------------------------------
sauer executes string as sauerbraten cubescript command and returns result back to lua
SYNTAX: sauer("string")
basically makes any cubescript command available to LUA scripts
sauer_getplayerinfo returns players info to lua
SYNTAX: sauer_getplayerinfo(CN,TYPE1,TYPE2,TYPE3, ...) will return multiple results to lua
types: 123 xyz, 4pitch, 5yaw, 678velocity
9 HP, 10 AR, 11 AT, 12 GUN, 13 STATE, 14 velocity, 15 timeinair, 16 name, 17 team
STATE : 0 alive; 1 dead, 3 lagged; 4 coopedit
sauer_setplayerinfo sets players info
SYNTAX: sauer_setplayerinfo(TYPE,VALUE)
sets info type to value, see types at sauer_getplayerinfo
sauer_getcubeinfo detect which cube player is looking at (or at players position) and returns distance,
textures, material
SYNTAX: sauer_getcubeinfo(cn,vx,vy,vz,dist,type)
cn is players cn, vx vy vz is direction vector, dist how far to look (default 0)
vx=0,vy=0,vz=0: returns current position cube data
type: -2: distance to hit point on cube, -1: material; 0-5: face texture
sauer_lookupcube selects cube at given position and returns its info
SYNTAX: sauer_lookupcube(x,y,z,type1,type2... )
returns multiple results to lua
type: 0-2: faces, 3 - 8 : textures, 9 : material
sauer_build builds a cube (local player only) with specified shape/position/textures
SYNTAX: sauer_build(x,y,z,grid,face1,face2,face3,tex1,tex2,tex3,tex4,tex5,tex6)
solid face = 0x80808080, coord range = 0...2^mapsize, grid = 1...mapsize
EXAMPLE: a.lua, function build_cube()
sauer_sel read current selection info
SYNTAX sauer_sel(type1,type2...)
returns multiple results to lua
type: 0 : o.x 1: o.y 2: o.z 3: s.x 4: s.y 5: s.z 6: grid
7: cx 8: cxs 9: cy 10: cys 11: orient 12: corner
EXAMPLE: a.lua, function sauersel()
sauer_copy copies specified area
SYNTAX sauer_copy(selox seloy seloz selsx selsy selsz selgrid selcx selcy selcys selorient selcorner)
EXAMPLE: misc.lua, function typechar(i,j)
sauer_paste pastes specified area
SYNTAX sauer_paste(selox seloy seloz selsx selsy selsz selgrid selcx selcy selcys selorient selcorner)
EXAMPLE: misc.lua, function typechar(i,j)
sauer_editface deform cubes as by scrolling the mouse
SYNTAX sauer_editface(ox,oy,oz, sx,sy,sz,grid, cx, cxs,cy,cys, orient, corner, dir,mode = 1)
dir = 1 push in (delete) cube, dir = -1 pull out (create) cube
cx, cxs, cy, cys : specify what part of face to push/pull,
orient : what face (0 = x direction, 1 = -x direction, 2,3 = +- y dir., 4 bottom (+z) ,5 top (-z)
corner: what part of face is targeted : 0,1,3,2 (counterclokwise starting at bottom left)
note: too see the numbers while editing, type /cmedebug 1 (0 do disable)
sauer_edittex change cube texture
SYNTAX sauer_edittex(ox,oy,oz, sx,sy,sz,grid, cx, cxs,cy,cys, orient, corner, tex, allfaces)
tex : what texture number to apply
allfaces: 0: only on selected face, 1: on all faces of cube
sauer_texinfo returns vscroll data for specified texture number
Sauerbraten game events with LUA:
--------------------------------
lua_edit_control controls what edit operations are accepted, is called when edit is about to be received
lua_N_TEXT is called when player receives text (talk from other players)
lua_N_EDITMODE is called when edit toggle occurs
lua_N_SHOTFX is called when some player shoots
lua_N_DAMAGE is called when some player damages other player
lua_N_DIED is called when some player dies
Other c++ functions available with FFI library:
-----------------------------------------------
bool sauer_hashstring(const char *str, char *result, int maxlen)
tiger hash, see a.lua, function tigerhash( text ) for more details
void sauer_editent(int i, float x, float y, float z, int type, int attr1, int attr2, int attr3, int attr4, int attr5, bool local)
entity manipulation routine. see a.lua, function test_ent for more details
int cmloadimage(char *filename, int width, int height, int *R, int *G, int *B);
loads jpg or png image and resamples it to requested dimension. Color data is put inside R,G,B tables
(each entry is number 0-255). For example usage see a.lua, function build_image.