Difference between revisions of "Dirrev.tf"

From AvatarWiki
Jump to navigation Jump to search
(New page: Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com'' Non issue: The script won't revert 3w200s, max supported is 99. <pre> /echo -aCyellow %% ...)
 
(mutter at wiki whitespace stuff)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
 
 
 
Non issue: The script won't revert 3w200s, max supported is 99.
 
Non issue: The script won't revert 3w200s, max supported is 99.
  
 
<pre>
 
<pre>
/echo -aCyellow %% /dirrev <path>     Revert speedwalk path
+
/echo -aCyellow %% /dirrev <path>       Revert speedwalk path
  
 
/def -i dirrev = \
 
/def -i dirrev = \
    /set dir_str %1 %;\
+
        /if ({#}=0) \
    /set dir_length $[strlen(dir_str)] %;\
+
                /echo -p %%% @{Cred}Syntax: /%{0} <path>@{n}%;\
    /set double_digit=0%;\
+
        /else \
    /set dir_rev=%;\
+
                /let _dir_str %1 %;\
    /for c 0 $[dir_length-1] \
+
                /let _length $[strlen(_dir_str)] %;\
        /set position $$[dir_length-c] %%;\
+
                /let _double_digit=0%;\
        /set cur_char $$[substr(dir_str, position-1, 1)] %%;\
+
                /set dirrev=%;\
        /set new_char %%{cur_char} %%;\
+
                /for c 0 $[_length-1] \
        /if (cur_char =~ "e") /set new_char w %%;/endif %%;\
+
                        /let _position $$[_length-c] %%;\
        /if (cur_char =~ "s") /set new_char n %%;/endif %%;\
+
                        /let _cur_char $$[substr(_dir_str, _position-1, 1)] %%;\
        /if (cur_char =~ "w") /set new_char e %%;/endif %%;\
+
                        /if (_cur_char =~ "e") /let _new_char w %%;\
        /if (cur_char =~ "n") /set new_char s %%;/endif %%;\
+
                        /elseif (_cur_char =~ "s") /let _new_char n %%;\
        /if (cur_char =~ "u") /set new_char d %%;/endif %%;\
+
                        /elseif (_cur_char =~ "w") /let _new_char e %%;\
        /if (cur_char =~ "d") /set new_char u %%;/endif %%;\
+
                        /elseif (_cur_char =~ "n") /let _new_char s %%;\
        /if ((new_char =/ "[0-9]") & (!double_digit)) \
+
                        /elseif (_cur_char =~ "u") /let _new_char d %%;\
            /set dir_rev $$[strcat(substr(dir_rev, 0, c-1), new_char, substr(dir_rev, c-1, 1))] %%;\
+
                        /elseif (_cur_char =~ "d") /let _new_char u %%;\
            /if (substr(dir_str, position-2, 1) =/ "[0-9]") \
+
                        /else  /let _new_char %%{_cur_char} %%;\
                /set dir_rev $$[strcat(substr(dir_rev, 0, c-1), substr(dir_str, position-2, 1), substr(dir_rev, c-1, 2))] %%;\
+
                        /endif %%;\
                /set double_digit 1 %%;\
+
                        /if ((_new_char =/ "[0-9]") & (!_double_digit)) \
            /endif %%;\
+
                                /set dirrev $$[strcat(substr(dirrev, 0, c-1), _new_char, substr(dirrev, c-1, 1))] %%;\
        /elseif ( regmatch("[nsewud]", new_char) ) \
+
                                /if (substr(_dir_str, _position-2, 1) =/ "[0-9]") \
            /set dir_rev $$[strcat(dir_rev, new_char)] %%;\
+
                                        /set dirrev $$[strcat(substr(dirrev, 0, c-1), substr(_dir_str, _position-2, 1), substr(dirrev, c-1, 2))] %%;\
            /set double_digit 0 %%;\
+
                                        /let _double_digit 1 %%;\
        /endif %;\
+
                                /endif %%;\
    /echo %%% the reverse of %dir_str is %dir_rev
+
                        /elseif ( regmatch("[nsewud]", _new_char) ) \
 +
                                /set dirrev $$[strcat(dirrev, _new_char)] %%;\
 +
                                /let _double_digit 0 %%;\
 +
                        /endif %;\
 +
                /echo -p %%% @{Cwhite}The reverse of @{Cgreen}%{_dir_str} @{Cwhite}is @{Cgreen}%dirrev@{n}%;\
 +
                /return "%dirrev"%;\
 +
        /endif
 
</pre>
 
</pre>
 
 
 
[[Category: TinyFugue Scripting]]
 
[[Category: TinyFugue Scripting]]

Latest revision as of 19:37, 9 November 2008

Non issue: The script won't revert 3w200s, max supported is 99.

/echo -aCyellow %% /dirrev <path>        Revert speedwalk path

/def -i dirrev = \
        /if ({#}=0) \
                /echo -p %%% @{Cred}Syntax: /%{0} <path>@{n}%;\
        /else \
                /let _dir_str %1 %;\
                /let _length $[strlen(_dir_str)] %;\
                /let _double_digit=0%;\
                /set dirrev=%;\
                /for c 0 $[_length-1] \
                        /let _position $$[_length-c] %%;\
                        /let _cur_char $$[substr(_dir_str, _position-1, 1)] %%;\
                        /if (_cur_char =~ "e") /let _new_char w %%;\
                        /elseif (_cur_char =~ "s") /let _new_char n %%;\
                        /elseif (_cur_char =~ "w") /let _new_char e %%;\
                        /elseif (_cur_char =~ "n") /let _new_char s %%;\
                        /elseif (_cur_char =~ "u") /let _new_char d %%;\
                        /elseif (_cur_char =~ "d") /let _new_char u %%;\
                        /else  /let _new_char %%{_cur_char} %%;\
                        /endif %%;\
                        /if ((_new_char =/ "[0-9]") & (!_double_digit)) \
                                /set dirrev $$[strcat(substr(dirrev, 0, c-1), _new_char, substr(dirrev, c-1, 1))] %%;\
                                /if (substr(_dir_str, _position-2, 1) =/ "[0-9]") \
                                        /set dirrev $$[strcat(substr(dirrev, 0, c-1), substr(_dir_str, _position-2, 1), substr(dirrev, c-1, 2))] %%;\
                                        /let _double_digit 1 %%;\
                                /endif %%;\
                        /elseif ( regmatch("[nsewud]", _new_char) ) \
                                /set dirrev $$[strcat(dirrev, _new_char)] %%;\
                                /let _double_digit 0 %%;\
                        /endif %;\
                /echo -p %%% @{Cwhite}The reverse of @{Cgreen}%{_dir_str} @{Cwhite}is @{Cgreen}%dirrev@{n}%;\
                /return "%dirrev"%;\
        /endif