diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-05-02 10:33:30 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-05-02 10:33:30 -0300 |
commit | 1634ecb4f96c531de6fb79ddd88d506e4b4e6e5c (patch) | |
tree | 5e4cfe0b8b078364e9e8dce44105af5bd83bf6b0 /npc/functions/util.txt | |
parent | 979ba62545c83782f2faf5f5426629024056165c (diff) | |
download | serverdata-1634ecb4f96c531de6fb79ddd88d506e4b4e6e5c.tar.gz serverdata-1634ecb4f96c531de6fb79ddd88d506e4b4e6e5c.tar.bz2 serverdata-1634ecb4f96c531de6fb79ddd88d506e4b4e6e5c.tar.xz serverdata-1634ecb4f96c531de6fb79ddd88d506e4b4e6e5c.zip |
raise Exception() - I mean, return Exception. Along a proof-of-use.
Diffstat (limited to 'npc/functions/util.txt')
-rw-r--r-- | npc/functions/util.txt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 6e390a70b..60274204e 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -650,3 +650,55 @@ function script gettimeparam { return .@t; } + +// Bug Warning +// ReportBug( BugID, {Flags{, Return Code}} ) +function script ReportBug { + // Fill variable + .@msg$=getarg(0); + .@gf=getarg(1,RB_DEFAULT); + + if (.@gf & RB_DISPBOTTOM) + dispbottom("ERROR: "+.@msg$); + + if (.@gf & RB_DEBUGMES) + debugmes("[Warning] "+.@msg$); + + if (.@gf & RB_SPEECH) + mesc("ERROR, REPORT ME! "+.@msg$, 1); + + if (.@gf & RB_PLEASEREPORT) + dispbottom("Please take a screenshot and report this bug, explaining how it happened."); + + if (.@gf & RB_ISFATAL) { + if (.@gf & RB_SPEECH) { + mesc l("This error is fatal."), 1; + close; + } + if (.@gf & RB_DISPBOTTOM) + dispbottom("This error is fatal, we stop execution."); + + if (.@gf & RB_DEBUGMES) + debugmes("[Error] The error is fatal."); + end; + } + + return getarg(2, 0); + +} + +// Upon entering a town +// EnterTown( LocName ) +function script EnterTown { + // Fill variable + .@v$=getarg(0); + + // Validade variable, see npc/000-1/exit.txt first + setarray .@locs$, "Candor", "Tulim", "Halin", "Hurns", "LoF", "Lilit", "Nival", "Frostia"; + if (array_find(.@locs$, .@v$) < 0) + return ReportBug("Invalid location passed to EnterTown: "+.@v$); + + LOCATION$=.@v$; + return; +} + |