* added "help" script with some basic information (as suggested by Visagalis). detailed help about specific commands not yet written.
* fixed major bug in the DefScript interpreter that could cause a DefReturnResult to return from the calling function too early and terminate the whole call stack. this could lead to scripts beeing executed only to half and then suddenly aborting execution without any sign that something went wrong. * "ljoin"-func does now accept start and end list index to join
This commit is contained in:
parent
14a2a04e94
commit
65a8ab523a
86
bin/scripts/help.def
Normal file
86
bin/scripts/help.def
Normal file
@ -0,0 +1,86 @@
|
||||
#script=help
|
||||
|
||||
set,argstr ?{lowercase ${@def}}
|
||||
lsplit,args,{ } ${argstr}
|
||||
|
||||
out == ${@version} :: help ==
|
||||
|
||||
if ?{not ?{llen args}}
|
||||
log - type "help list" to list all avalible help topics
|
||||
out - type "help basic" for some basic usage information.
|
||||
out >> visit http:\//www.mangosclient.org for more information
|
||||
out - type "help <cmd>" to see detailed information about a command
|
||||
return
|
||||
endif
|
||||
|
||||
if ?{equal,basic ?{lindex,args 0}}
|
||||
out >> "say ..." to say something (might not work on servers blocking global language).
|
||||
out >> "say,<language> ..." to say something in specified language (ID or name).
|
||||
out >> "yell", "sayguild", "sayparty" is used in the same manner.
|
||||
out >> there is a fun command, "sl,<language> <text>" that says text in leetspeak.
|
||||
out >> "whisper,<playername>,<language>" to whisper to a player, language is optional, like in "say".
|
||||
out >> "joinchannel <channelname>" joins a channel, "leavechannel <...>" leaves a channel".
|
||||
out >> "chan,<channelname>,<language> <text>" says something in a channel. language is optional.
|
||||
out >> "me <emote>" performs an emote. ID or emote name can be used.
|
||||
return
|
||||
endif
|
||||
|
||||
if ?{equal,list ?{lindex,args 0}}
|
||||
== Help topics avalible: ?{llen reg_name}
|
||||
set,i 0
|
||||
loop
|
||||
if ?{bigger_eq,${i} ?{llen reg_name}}
|
||||
exitloop
|
||||
endif
|
||||
out "help ?{lindex,reg_name ${i}}"
|
||||
endloop
|
||||
return
|
||||
endif
|
||||
|
||||
set,i ?{lfind,reg_name ?{lindex,args 0}}
|
||||
if ?{strlen ${i}}
|
||||
?{lindex,reg_func ${i}} ?{ljoin,args { }} // call the function attached to the specified name, with all args passed to this func
|
||||
else
|
||||
logerror No help exists for "${argstr}"...
|
||||
endif
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=RegisterHelpTopic
|
||||
//--------------------------------------------------------
|
||||
// @def: topic name "help <this>"
|
||||
// @0: function name to call
|
||||
set,topic ?{lowercase ${@def}}
|
||||
set,func ?{lowercase ${@0}}
|
||||
if ?{not ?{strlen ${topic}}}
|
||||
return
|
||||
endif
|
||||
if ?{not ?{strlen ${name}}}
|
||||
return
|
||||
endif
|
||||
|
||||
if ?{not ?{lcontains,#help::reg_name ${topic}}}
|
||||
lappend,#help::reg_name ${topic}
|
||||
lappend,#help::reg_func ${func}
|
||||
endif
|
||||
|
||||
|
||||
|
||||
//======================================================================================
|
||||
//=== Help for some internal/predefined commands =======================================
|
||||
//======================================================================================
|
||||
|
||||
#script=dummy
|
||||
#onload
|
||||
RegisterHelpTopic,help__say say
|
||||
RegisterHelpTopic,help__yell yell
|
||||
RegisterHelpTopic,help__chan chan
|
||||
RegisterHelpTopic,help__sl sl
|
||||
#/onload
|
||||
|
||||
|
||||
|
||||
#script=help__say
|
||||
// to be written.....
|
||||
|
||||
@ -28,8 +28,8 @@ struct DefReturnResult
|
||||
DefReturnResult() { ok=true; mustreturn=false; ret="true"; }
|
||||
DefReturnResult(bool b) { ok=true; mustreturn=false; ret=b?"true":"false"; }
|
||||
DefReturnResult(std::string s) { ok=true; mustreturn=false; ret=s; }
|
||||
DefReturnResult(const char *s) { DefReturnResult(std::string(s)); }
|
||||
DefReturnResult(char *s) { DefReturnResult(std::string(s)); }
|
||||
DefReturnResult(const char *s) { ok=true; mustreturn=false; ret=s; }
|
||||
DefReturnResult(char *s) { ok=true; mustreturn=false; ret=s; }
|
||||
bool ok; // true if the execution of the current statement was successful
|
||||
bool mustreturn;
|
||||
std::string ret; // return value used by ?{..}
|
||||
|
||||
@ -159,8 +159,12 @@ DefReturnResult DefScriptPackage::func_ljoin(CmdSet& Set)
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
for(unsigned int i = 0; i < l->size(); i++)
|
||||
return "";
|
||||
unsigned int start_from = (unsigned int)toUint64(Set.arg[1]);
|
||||
unsigned int end_at = (unsigned int)toUint64(Set.arg[2]);
|
||||
if(!end_at)
|
||||
end_at = l->size();
|
||||
for(unsigned int i = start_from; i < end_at; i++)
|
||||
{
|
||||
r += (*l)[i];
|
||||
if( i+1 != l->size() )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user