* added script to support /me-like emotes (scriptname is "me")
* changed the permission system: now a script cant be used as game command f no permission is explicitly set
* implemented threadsafe CLI queue to solve crashes with short-intervalled events that ran on 2 threads
* fixed name return at "getitemprotovalue" script
* iplemented DrawObject class and a Mgr for those objects; they will ease object drawing once implemented. the Mgr works under control of the GUI thread and is threadsafe.
* implemented auto-loading of SCP files if a name-tag is present somewhere in the file ("#dbname=...") and no explicit db name was passed to "loadscp" script.
* changed internal ObjMgr storage to std::map (instead of list) for faster access
* fixed call of "_enterworld" script
* fixed handling of MyCharacter(), which could cause crashes after newly changes
* fixed GetFileList() func in tools.cpp (this fixes also related "lgetfiles" script func). now it will only parse files, not directories. might still need some fixing for linux.
142 lines
3.8 KiB
Modula-2
142 lines
3.8 KiB
Modula-2
// core functions. required by other scripts to run!
|
|
#onload
|
|
log * Loading core scripts...
|
|
#/onload
|
|
|
|
|
|
//--------------------------------------------------------
|
|
#script=append
|
|
//--------------------------------------------------------
|
|
// usage: append text to a string.
|
|
// args:
|
|
// @def: text to append
|
|
// @0: variable to which the text should be appended
|
|
|
|
// get the var name if the original variable
|
|
SET,v #${@caller}::${@0}
|
|
// if it has not been set before, init it now
|
|
DEFAULT,${v}
|
|
// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got.
|
|
SET,${v} ${${v}}${@def}
|
|
// remove the name placeholder
|
|
UNSET v
|
|
|
|
|
|
//--------------------------------------------------------
|
|
#script=exloadscp
|
|
#permission=255
|
|
//--------------------------------------------------------
|
|
if ?{fileexists ${@def}}
|
|
loadscp,{${@0}} ${@def}
|
|
else
|
|
logdebug skipped loading of non-existent file '${@def}'
|
|
endif
|
|
|
|
|
|
//--------------------------------------------------------
|
|
#script=loadallscp
|
|
#permission=255
|
|
//--------------------------------------------------------
|
|
LOG * Loading SCP data storages...
|
|
|
|
// example:
|
|
// LOADSCP,test data/test.scp
|
|
|
|
// load default databases
|
|
LOADSCP,class data/scp/class.scp
|
|
LOADSCP,gender data/scp/gender.scp
|
|
LOADSCP,language data/scp/language.scp
|
|
LOADSCP,map data/scp/map.scp
|
|
LOADSCP,race data/scp/race.scp
|
|
|
|
// load extended databases if present.
|
|
EXLOADSCP,sound data/scp/sound.scp
|
|
EXLOADSCP,emote data/scp/emote.scp
|
|
EXLOADSCP,area data/scp/area.scp
|
|
|
|
LOG * SCP loaded.
|
|
|
|
|
|
//-------------------------------------------------
|
|
#script=string_is_command
|
|
//-------------------------------------------------
|
|
// purpose: detect if @def might be a server command.
|
|
|
|
// split all chars we have set in the config files to a list.
|
|
lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS}
|
|
|
|
// find out the first char of the string
|
|
SET,c ?{SUBSTR,1 ${@def}}
|
|
|
|
// does the char list contain our first char? if yes it can trigger a server command.
|
|
if ?{lcontains,#CMDCHARLIST ${c}}
|
|
unset c
|
|
return true
|
|
endif
|
|
unset c
|
|
return false
|
|
|
|
|
|
//--------------------------------------------------------
|
|
#script=normalize_name
|
|
//--------------------------------------------------------
|
|
// uppercases first char, lowercases rest
|
|
set,name ?{uppercase ?{substr,1 ${@def}}}
|
|
set,len ?{strlen ${@def}}
|
|
sub,len 1
|
|
append,name ?{lowercase ?{substr,${len},1 ${@def}}}
|
|
return ${name}
|
|
|
|
//---------------------------------------------------------
|
|
#script=globname
|
|
//---------------------------------------------------------
|
|
// purpose: returns the global name of a variable
|
|
// args: @def: var name, @0 (optional): name of the intended parent func
|
|
set,c ?{substr,1 ${@def}}
|
|
// it is a global var if the varname starts with # or there is no caller script
|
|
if ?{or,?{equal,# ${c}} ?{not ${@caller}}}
|
|
return ${@def}
|
|
endif
|
|
set,top ${@0}
|
|
default,top ${@caller}
|
|
return #${top}::${@def}
|
|
|
|
|
|
//---------------------------------------------------------
|
|
#script=getvar
|
|
//---------------------------------------------------------
|
|
// purpose: returns the value of a variable. if the variable hasnt been set return empty string.
|
|
set,top ${@caller}
|
|
default,top #
|
|
set,v ?{globname,${top} ${@def}}
|
|
unset top
|
|
out getvar: v=${v} -> ${${v}}
|
|
if ?{isset ${v}}
|
|
return ${${v}}
|
|
endif
|
|
return
|
|
|
|
//---------------------------------------------------------
|
|
#script=reverse
|
|
//---------------------------------------------------------
|
|
// purpose: reverse a srtring
|
|
// args: @def: string to reverse
|
|
// returns: reversed string
|
|
|
|
set,outstr
|
|
set,elems ?{lsplit,mylist ${@def}}
|
|
set,i ${elems}
|
|
loop
|
|
sub,i 1
|
|
if ?{equal,${i} -1}
|
|
exitloop
|
|
endif
|
|
append,outstr ?{lindex,mylist ${i}}
|
|
endloop
|
|
ldelete mylist
|
|
return ${outstr}
|
|
|
|
|
|
|
|
|