diff options
author | Joseph Botosh <rumly111@gmail.com> | 2015-09-24 22:07:28 +0300 |
---|---|---|
committer | Joseph Botosh <rumly111@gmail.com> | 2015-09-24 22:07:28 +0300 |
commit | 27fc261dcbfbbe20611efbb4aac8bf7a1d91009a (patch) | |
tree | 2d070e53c4132976751a3b8c63f456b62637a28a | |
parent | d5af6dc2694023735287ba9eb285f0b415165ad0 (diff) | |
download | serverdata-27fc261dcbfbbe20611efbb4aac8bf7a1d91009a.tar.gz serverdata-27fc261dcbfbbe20611efbb4aac8bf7a1d91009a.tar.bz2 serverdata-27fc261dcbfbbe20611efbb4aac8bf7a1d91009a.tar.xz serverdata-27fc261dcbfbbe20611efbb4aac8bf7a1d91009a.zip |
update function narrator and speech: using optional bit flags as first arg
-rw-r--r-- | npc/functions/main.txt | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt index f44fb44e..d510f05b 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -78,51 +78,76 @@ function script strip { // Function to show narrator text. Accepts string args. -// If first arg is a number N, it prints N blank lines at beginning. -// Default number of blank lines is 1. +// If first arg is a number N, then it represents bit flags. +// Bit flags : +// 0x1 -- blank line at beginning +// 0x2 -- blank line at the end +// 0x4 -- use last "next;" function script narrator { .@start = 0; - .@blank_lines = 1; - if (getargcount() > 1 && !isstr(getarg(0))) + .@argc = getargcount(); + .@flags = 0; + + if (.@argc > 1 && !isstr(getarg(0))) { .@start = 1; - .@blank_lines = getarg(0); + .@flags = getarg(0); } - for (.@i = 0; .@i < .@blank_lines; .@i++) + if (.@flags & 0x1) mes ""; mes l("[Narrator]"); - for (.@i = .@start; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < .@argc; .@i++) { mes col(getarg(.@i), 9); - next; + if (.@i < .@argc - 1) + next; } + + if (.@flags & 0x4) + next; + else if (.@flags & 0x2) + mes ""; + return; } // Function to show NPC speech. Accepts string args. -// If first arg is a number N, it prints N blank lines at beginning. -// Default number of blank lines is 1. +// If first arg is a number N, then it represents bit flags. +// Bit flags : +// 0x1 -- blank line at beginning +// 0x2 -- blank line at the end +// 0x4 -- use last "next;" function script speech { .@start = 0; - .@blank_lines = 1; - if (getargcount() > 1 && !isstr(getarg(0))) + .@argc = getargcount(); + .@flags = 0; + + if (.@argc > 1 && !isstr(getarg(0))) { .@start = 1; - .@blank_lines = getarg(0); + .@flags = getarg(0); } - for (.@i = 0; .@i < .@blank_lines; .@i++) + if (.@flags & 0x1) mes ""; mesn; - for (.@i = .@start; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < .@argc; .@i++) { mesq getarg(.@i); - next; + + if (.@i < .@argc - 1) + next; } + + if (.@flags & 0x4) + next; + else if (.@flags & 0x2) + mes ""; + return; } |