diff --git a/bin/scripts/help.def b/bin/scripts/help.def new file mode 100644 index 0000000..9f17c33 --- /dev/null +++ b/bin/scripts/help.def @@ -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 " 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, ..." 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, " that says text in leetspeak. + out >> "whisper,," to whisper to a player, language is optional, like in "say". + out >> "joinchannel " joins a channel, "leavechannel <...>" leaves a channel". + out >> "chan,, " says something in a channel. language is optional. + out >> "me " 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 " +// @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..... + diff --git a/src/Client/DefScript/DefScript.h b/src/Client/DefScript/DefScript.h index 471e6ba..d22ee94 100644 --- a/src/Client/DefScript/DefScript.h +++ b/src/Client/DefScript/DefScript.h @@ -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 ?{..} diff --git a/src/Client/DefScript/DefScriptListFunctions.cpp b/src/Client/DefScript/DefScriptListFunctions.cpp index 688bed9..a12c3ed 100644 --- a/src/Client/DefScript/DefScriptListFunctions.cpp +++ b/src/Client/DefScript/DefScriptListFunctions.cpp @@ -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() )