From ba1e827b6b4c17c35a163e6b55be8c122de632b8 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 10 Apr 2021 03:00:20 -0300 Subject: Add several convenience functions. Fix some bugs regarding misuse of readparam() --- npc/commands/language.txt | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 npc/commands/language.txt (limited to 'npc/commands/language.txt') diff --git a/npc/commands/language.txt b/npc/commands/language.txt new file mode 100644 index 00000000..ce7122f5 --- /dev/null +++ b/npc/commands/language.txt @@ -0,0 +1,60 @@ +// TMW2 Script +// Author: Jesusalva +// With code parts from Julia (Evol) + +// @lang atcommand +// Changes Language +// +// group lv: 0 +// group char lv: 0 +// log: False +// +// usage: +// @lang +// + +function script CMD_lang { + callfunc "checkclientversion"; + mesq l("Which language do you speak?"); + next; + asklanguage(LANG_IN_SHIP); + mes ""; + mesn; + mesq l("Ok, done."); + return; +} + +- script @lang 32767,{ + end; + +OnCall: + CMD_lang(); + close; + +OnTranslate: + // Implode, using a slash at whitespaces + .@request$ = implode(.@atcmd_parameters$, "%2F"); + // No NPC provided? + if (.@request$ == "") { + dispbottom l("Usage: @translate "); + dispbottom l("Example: @translate Nard"); + dispbottom l("Example: @translate Elmo"); + dispbottom l("Example: @translate npc/002-1/arpan"); + dispbottom l("PS. Doesn't always work. You need an account at %s and to be at ManaPlus Team.", "@@https://www.transifex.com/arctic-games|Transifex@@"); + end; + } + // Add .txt extension of needed + if (!compare(.@request$, ".txt")) + .@request$ += ".txt"; + // Fix stuff for URL format + .@request$ = replacestr(.@request$, "/", "%2F"); + .@request$ = strtolower(.@request$); + // Give your translation link + dispbottom "@@https://www.transifex.com/arctic-games/moubootaur-legends/translate/#"+languagecode()+"/serverdata?q=occurrence%3A"+.@request$+"|Translate with Transifex@@"; + close; + +OnInit: + bindatcmd "lang", "@lang::OnCall", 0, 60, 0; + bindatcmd "translate", "@lang::OnTranslate", 0, 60, 0; + end; +} -- cgit v1.2.3-60-g2f50