Mercurial > hg > batmud > ggrtf
changeset 326:6e10442a8432
v0.5.9.29: Improved error checking in various /def*-macros; /defvar functionality and syntax changed, added possibility to have comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 08 Mar 2006 13:17:54 +0000 |
parents | 0416da54a325 |
children | 521d0c3233bd |
files | ggrtf.tf |
diffstat | 1 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ggrtf.tf Wed Mar 08 11:44:52 2006 +0000 +++ b/ggrtf.tf Wed Mar 08 13:17:54 2006 +0000 @@ -1,8 +1,8 @@ ;; -;; GgrTF v0.5.9.28-svn - TinyFugue script for BatMUD +;; GgrTF v0.5.9.29-svn - TinyFugue script for BatMUD ;; (C) Copyright 2004-2006 Matti Hämäläinen (Ggr Pupunen) ;; -/set ggrtf_ver=0.5.9.28-svn +/set ggrtf_ver=0.5.9.29-svn ;; ;; This triggerset is Free Software distributed under ;; GNU General Public License version 2. @@ -199,6 +199,7 @@ /set lst_options= /def -i deftoggle =\ /if (!getopts("n:d:", "")) /gerror Invalid toggle creation command!%;/break%;/endif%;\ + /if (opt_n=~""|opt_d=~"") /gerror Required arguments not specified!%;/break%;/endif%;\ /set lst_options=%{opt_n} %{lst_options}%;\ /set opt_%{opt_n}_d=%{opt_d}%;\ /eval /def -i %{opt_n} =\ @@ -218,6 +219,7 @@ /set lst_values= /def -i defvalue =\ /if (!getopts("n:d:", "")) /gerror Invalid value setting creation command!%;/break%;/endif%;\ + /if (opt_n=~""|opt_d=~"") /gerror Required arguments not specified!%;/break%;/endif%;\ /set lst_values=%{opt_n} %{lst_values}%;\ /set set_%{opt_n}_d=%{opt_d}%;\ /eval /def -i %{opt_n} =\ @@ -251,6 +253,7 @@ /def -i defsetting =\ /if (!getopts("n:d:s:", "")) /gerror Invalid setting creation command!%;/break%;/endif%;\ + /if (opt_n=~""|opt_d=~""|opt_s=~"") /gerror Required arguments not specified!%;/break%;/endif%;\ /set lst_settings=%{opt_n} %{lst_settings}%;\ /set set_%{opt_n}_d=%{opt_d}%;\ /set set_%{opt_n}_s=%{opt_s}%;\ @@ -274,6 +277,7 @@ /set lst_hooks= /def -i defhook =\ /if (!getopts("n:d:s:h:", "")) /gerror Invalid function hook setting creation command!%;/break%;/endif%;\ + /if (opt_n=~""|opt_d=~""|opt_s=~""|opt_h=~"") /gerror Required arguments not specified!%;/break%;/endif%;\ /set lst_hooks=%{opt_n} %{lst_hooks}%;\ /set set_%{opt_n}_d=%{opt_d}%;\ /set set_%{opt_n}_s=%{opt_s}%;\ @@ -297,13 +301,26 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Define a global, saveable variable /def -i defvar =\ - /set lst_savevars=%{1} %{lst_savevars}%;\ - /eval /set %{1}=%{-1} + /if (!getopts("n:v:c:", "")) /gerror Invalid save variable definition!%;/break%;/endif%;\ + /if (opt_n=~"") /gerror No variable name option specified.%;/break%;/endif%;\ + /if (opt_c) /set comment_%{opt_n}=%{opt_c}%;/endif%;\ + /set lst_savevars=%{opt_n} %{lst_savevars}%;\ + /if (opt_v)\ + /eval /set %{opt_n}=%{opt_v}%;\ + /endif ;; Save given list of variables (set 'gsave_varpref' to prefix) /def -i gsave_vars =\ /while ({#})\ + /eval /set qtmpa=%%{comment_%{1}}%;\ + /if (qtmpa!~"")\ + /set qtmpa=;; %{qtmpa}%;\ + /if (tfwrite(gsave_file,qtmpa) < 0) \ + /gerror Error writing to file '@{Cyellow}%{gsave_filename}@{n}'!%;\ + /return%;\ + /endif%;\ + /endif%;\ /eval /set qtmpa=/eval /set %{gsave_varpref}%{1}=%%{%{gsave_varpref}%{1}}%;\ /if (tfwrite(gsave_file,qtmpa) < 0) \ /gerror Error writing to file '@{Cyellow}%{gsave_filename}@{n}'!%;\