Difference between revisions of "Dirrev.tf"
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 %% ...) |
(Added a check if no argument was given to show the syntax and added some color to the result echo.) |
||
| Line 7: | Line 7: | ||
/def -i dirrev = \ | /def -i dirrev = \ | ||
| − | /set dir_str %1 %;\ | + | /if ({#}=0) \ |
| − | + | /echo -p %%% @{Cred}Syntax: /%{0} <path>@{n}%;\ | |
| − | + | /else \ | |
| − | + | /set dir_str %1 %;\ | |
| − | + | /set dir_length $[strlen(dir_str)] %;\ | |
| − | + | /set double_digit=0%;\ | |
| − | + | /set dir_rev=%;\ | |
| − | + | /for c 0 $[dir_length-1] \ | |
| − | + | /set position $$[dir_length-c] %%;\ | |
| − | + | /set cur_char $$[substr(dir_str, position-1, 1)] %%;\ | |
| − | + | /set new_char %%{cur_char} %%;\ | |
| − | + | /if (cur_char =~ "e") /set new_char w %%;/endif %%;\ | |
| − | + | /if (cur_char =~ "s") /set new_char n %%;/endif %%;\ | |
| − | + | /if (cur_char =~ "w") /set new_char e %%;/endif %%;\ | |
| − | + | /if (cur_char =~ "n") /set new_char s %%;/endif %%;\ | |
| − | + | /if (cur_char =~ "u") /set new_char d %%;/endif %%;\ | |
| − | + | /if (cur_char =~ "d") /set new_char u %%;/endif %%;\ | |
| − | + | /if ((new_char =/ "[0-9]") & (!double_digit)) \ | |
| − | + | /set dir_rev $$[strcat(substr(dir_rev, 0, c-1), new_char, substr(dir_rev, c-1, 1))] %%;\ | |
| − | + | /if (substr(dir_str, position-2, 1) =/ "[0-9]") \ | |
| − | + | /set dir_rev $$[strcat(substr(dir_rev, 0, c-1), substr(dir_str, position-2, 1), substr(dir_rev, c-1, 2))] %%;\ | |
| − | + | /set double_digit 1 %%;\ | |
| − | + | /endif %%;\ | |
| − | + | /elseif ( regmatch("[nsewud]", new_char) ) \ | |
| − | + | /set dir_rev $$[strcat(dir_rev, new_char)] %%;\ | |
| + | /set double_digit 0 %%;\ | ||
| + | /endif %;\ | ||
| + | /echo -o %%% @{Cwhite}The reverse of @{Cgreen}%{dir_str} @{Cwhite}is @{Cgreen}%dir_rev@{n}%;\ | ||
| + | /endif | ||
</pre> | </pre> | ||
[[Category: TinyFugue Scripting]] | [[Category: TinyFugue Scripting]] | ||
Revision as of 12:15, 30 October 2008
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.
/echo -aCyellow %% /dirrev <path> Revert speedwalk path
/def -i dirrev = \
/if ({#}=0) \
/echo -p %%% @{Cred}Syntax: /%{0} <path>@{n}%;\
/else \
/set dir_str %1 %;\
/set dir_length $[strlen(dir_str)] %;\
/set double_digit=0%;\
/set dir_rev=%;\
/for c 0 $[dir_length-1] \
/set position $$[dir_length-c] %%;\
/set cur_char $$[substr(dir_str, position-1, 1)] %%;\
/set new_char %%{cur_char} %%;\
/if (cur_char =~ "e") /set new_char w %%;/endif %%;\
/if (cur_char =~ "s") /set new_char n %%;/endif %%;\
/if (cur_char =~ "w") /set new_char e %%;/endif %%;\
/if (cur_char =~ "n") /set new_char s %%;/endif %%;\
/if (cur_char =~ "u") /set new_char d %%;/endif %%;\
/if (cur_char =~ "d") /set new_char u %%;/endif %%;\
/if ((new_char =/ "[0-9]") & (!double_digit)) \
/set dir_rev $$[strcat(substr(dir_rev, 0, c-1), new_char, substr(dir_rev, c-1, 1))] %%;\
/if (substr(dir_str, position-2, 1) =/ "[0-9]") \
/set dir_rev $$[strcat(substr(dir_rev, 0, c-1), substr(dir_str, position-2, 1), substr(dir_rev, c-1, 2))] %%;\
/set double_digit 1 %%;\
/endif %%;\
/elseif ( regmatch("[nsewud]", new_char) ) \
/set dir_rev $$[strcat(dir_rev, new_char)] %%;\
/set double_digit 0 %%;\
/endif %;\
/echo -o %%% @{Cwhite}The reverse of @{Cgreen}%{dir_str} @{Cwhite}is @{Cgreen}%dir_rev@{n}%;\
/endif