OctaCore/config/stdlib.cfg

61 lines
1.8 KiB
INI

// Console language standard library
// Binds a key so that it will toggle a variable
bindvar = [bind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [echo @@arg2 ON]]]
bindvarquiet = [bind $arg1 [@arg2 (= $@arg2 0)]]
editbindvar = [editbind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [echo @@arg2 ON]]]
editbindvarquiet = [editbind $arg1 [@arg2 (= $@arg2 0)]]
// Binds a key so that it will set a modifier while held down
bindmod = [bind $arg1 [@arg2 1; onrelease [@@arg2 0]]]
editbindmod = [editbind $arg1 [@arg2 1; onrelease [@@arg2 0]]]
quine = [echo (format "quine = [%1]" $quine)]
issomeoneelsemaster = [
>= (listfind cn $listclients [ismaster $cn]) 0
]
numbots = [
listcount cn $listclients [isai $cn]
]
clearbots = [
looplist cn $listclients [
if (isai $cn) [delbot]
]
]
// Returns given RGB color as an INT color
// usage: (rgbtoint R G B)
rgbtoint = [+ (<< $arg1 16) (<< $arg2 8) $arg3]
// Returns given RGB color as a HEX color
// usage: (rgbtohex R G B)
rgbtohex = [tohex (rgbtoint $arg1 $arg2 $arg3) 6]
// Returns given INT color as an RGB color
// usage: (inttorgb <value> R-var G-var B-var)
inttorgb = [
$arg2 = (& (>> $arg1 16) 0xFF)
$arg3 = (& (>> $arg1 8) 0xFF)
$arg4 = (& $arg1 0xFF)
]
// *.tex file handling
texsky = [setshader "stdworld"; texture 0 "game/sky.png"]
texerror = [setshader "stdworld"; texture 0 "game/notexture.png"]
texnorender = [setshader "stdworld"; texture 0 "game/norender.png"]
texload = [
if (! (exec [media/texture/@arg1.tex] 0)) [
error [texload error: @arg1.tex not found]
texerror
]
]
decalload = [
if (! (exec [media/decal/@arg1.cfg] 0)) [
error [decalload error: @arg1.cfg not found]
]
]