diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-06-11 11:13:11 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-03-30 11:22:47 -0400 |
commit | bc4deaf81d9701261baac6a10d762b0f40e7f65f (patch) | |
tree | e539e3a49756626e27d4491fccb7a6862b12a120 /world/map/npc/commands/_procedures.txt | |
parent | 9e7f46ac732851c1359a15837c82ebf67ea2be39 (diff) | |
download | serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.gz serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.bz2 serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.xz serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.zip |
initial commit for magic v3
Fix Druid Tree and add hug to TMW
Diffstat (limited to 'world/map/npc/commands/_procedures.txt')
-rw-r--r-- | world/map/npc/commands/_procedures.txt | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/world/map/npc/commands/_procedures.txt b/world/map/npc/commands/_procedures.txt new file mode 100644 index 00000000..77c1c7e9 --- /dev/null +++ b/world/map/npc/commands/_procedures.txt @@ -0,0 +1,53 @@ +// ARGV Splitter +// takes @args$ and splits it properly so that '@cmd "foo bar" baz' is ['foo bar','baz'] instead of ['foo','bar','baz'] +// input: @args$ (string) +// output: @argv$ (array) and @argv (array) +function|script|argv_splitter +{ + explode .@fragments$, @args$, " "; + set .@e, 0; + set .@total, getarraysize(.@fragments$); + set .@NULL$, chr(3); // HACK: we use .@NULL$ as a workaround because we can't do "\0" + goto L_Check; + +L_Check: + setarray .@check$[0], "", .@NULL$, .@NULL$; + explode .@check$, .@fragments$[.@e], "\""; // check if the fragment contains a quote + if (.@check$[0] == "" && .@check$[1] != .@NULL$ && .@check$[1] != "" && .@check$[2] == .@NULL$) + set .@string$, .@check$[1]; // begin substring + elif (.@check$[0] != "" && .@check$[1] == "" && .@check$[2] == .@NULL$) + goto L_EndSubString; // end substring + elif (.@string$ != "" && .@check$[0] != "" && .@check$[1] == .@NULL$ && .@check$[2] == .@NULL$) + set .@string$, .@string$ +" "+ .@check$[0]; // part of the substring + elif (.@check$[2] != .@NULL$) goto L_Set2; // the the argument is quoted but there is no space + else goto L_Set; + goto L_CheckAfter; + +L_Set: + setarray @argv$[.@t], .@check$[0]; // not in a substring so push right away + setarray @argv[.@t], .@check$[0]; // not in a substring so push right away + set .@t, .@t + 1; + goto L_CheckAfter; + +L_Set2: + setarray @argv$[.@t], .@check$[1]; // not in a substring so push right away + setarray @argv[.@t], .@check$[1]; // not in a substring so push right away + set .@t, .@t + 1; + goto L_CheckAfter; + +L_EndSubString: + set .@string$, .@string$ + " " + .@check$[0]; + setarray @argv$[.@t], .@string$; // push in the array + setarray @argv[.@t], .@string$; // push in the array + set .@t, .@t + 1; + set .@string$, ""; // clean + goto L_CheckAfter; + +L_CheckAfter: + set .@e, .@e + 1; + if (.@e > .@total) goto L_Done; // the @argv$ array is built + goto L_Check; // not done yet + +L_Done: + return; +} |